Batch file to copy from remote desktop to local machine

19,890

Solution 1

In most cases, the access of drive c via network (\\Trail01\c$) is only allowed to administrators.

First of all you can check if you have the necessary rights to map the share \\Trail01\c$ (explorer >> map network drive).

If this is not possible, maybe you can try to create a new share when you are in a remote session on the server. Right-Click on the folder which you need access (in your case "c:\Users\ashique.sheikh\Desktop\Day2.R") in explorer >> properties >> sharing >> Advanced sharing.

If you could create a new share (which is called for example specialshare), please try to access via \\Trail01\specialshare.

Is this possible?

Solution 2

Well, first of all - You can't write \\Trail01\c:\, so you should change it with \\Trail01\c$\

Try something like this...

XCOPY /Y "\\Trail01\c$\users\ashique.sheikh\Desktop\Day2.R" "D:\VMI"

Or perhaps this...

    PushD "\\Trail01\c$\users\ashique.sheikh\Desktop" &&(
XCOPY /Y Day2.R "D:\VMI"
    ) & PopD
Share:
19,890
Ashique Sheikh
Author by

Ashique Sheikh

Updated on June 14, 2022

Comments

  • Ashique Sheikh
    Ashique Sheikh almost 2 years

    How do I copy a file from a remote desktop user's drive to my local machine using xcopy or any other protocol?

    My server path is \\\Trail01 and the file location is: C:\Users\ashique.sheikh\Desktop\Day2.R

    How can I use this is in my batch file?

    I have tried this:

    net use "\\\Trail01" "Trail01@1234" "/USER:ashique.sheikh"
    XCOPY /Y \\\Trail01\c:\users\ashique.sheikh\Desktop\Day2.R  "D:\VMI"
    

    But it doesn't work, it gives a path error.

    How can I download this or is there any other way to do it?