title: How to copy a file to a remote computer's desktop when the remote computer could be Windows 7 or XP?
body: <p>I'm trying to create a script that copies a file to the desktop of a remote user.  The two computers would be on the same network in the same domain.  </p>
  
  <p>So far I've got a batch script that looks something like:</p>
  
  <pre><code>@echo off
  set /p user="Username of remote user: "
  set /p hostname="Target computer name: "
  xcopy [path to local file] "\\%hostname%\c$\Users\%user%\Desktop\"
  </code></pre>
  
  <p>The above script would only work for Windows 7.  Is there a way to make it so that the script would somehow detect to see if the parent folder exists before copying, then if it does to copy?  Or can this be achieved with environment variables?</p>
  
  <p>If I just let the above script run as is and the target computer is using Windows XP, then a new directory tree will be created, which is what I'd like to avoid.</p>
  
  <p><a href="https://support.microsoft.com/kb/65994" rel="nofollow">https://support.microsoft.com/kb/65994</a>  would work if I were checking the local system, but I'm trying to see if the remote computer's destination folder exists.  I don't see how this article answers that.</p>