91

Is there a way I can launch a RDP session to a remote Windows server, and perform a file transfer to the local computer? Versions of the remote Windows Server varies. Ranges anywhere from 2000 to 2008.

I've tried to look up solutions and it seems scattered everywhere. Some suggest using mstsc.exe, others suggest PowerShell / Java / ASP Net. I'm confused. Appreciate some guidance here.

Thanks!

Update Below: 17 Feb 2012

Thanks for all suggestions. Would like to add that the remote servers are securely locked down and I'm not allowed to install SSH servers, FTP servers, or shared drives. The only way for accessing the remote machine is through RDP, and these machines are also on separate VLANs to which only authorised users can use RDP to access these machines. I'm trying to create a script that can help authorised users to download the required files.

louis xie
  • 1,352
  • 2
  • 12
  • 22
  • Do you need to use RDP? Can you install an SSH server on the remote windows server and transfer the files that way (using SCP) – Alan Feb 16 '12 at 03:09
  • If you can do an RDP session to the server, you should have access to the admin shares (C$, D$, etc) on the servers drives. You should be able to access and copy file through those without need RDP at all. – mjolinor Feb 16 '12 at 11:17
  • -Alan, I'm not allowed to install an SSH Server. -mjolinor, I'm not allowed to add shared drives either. – louis xie Feb 17 '12 at 00:46
  • Pretty much all (most? ... probably all...) methods of file transfer aren't available to you then. – Andy Arismendi Feb 17 '12 at 02:15
  • If I can use RDP to transfer files from the remote server to my local computer, the qn then is whether I can automate this process? – louis xie Feb 17 '12 at 03:30
  • Haha, this is so totally not an SO question, it's an SU question. – Steven Lu Jan 24 '14 at 02:50
  • I may be wrong, but I believe SU was not yet create at the time of writing? – louis xie Mar 17 '14 at 14:08

9 Answers9

86

You can map a drive using remote desktop.

Options > Local Resources > More

enter image description here

Andy Arismendi
  • 50,577
  • 16
  • 107
  • 124
  • Thanks, but I'm not allowed to do that. – louis xie Feb 17 '12 at 00:48
  • 3
    The RDP client needs to offer an option where the remote drives are brought to your local machine so that you can work remotely and can then sync files back to your local machine (where the sync is initiated locally), and it needs to be tunneled within the RDP session. Opening up your local drives to the remote machine is a much bigger security hole, at least for me. And regular SMB access to \\machine is not typically feasible to remote Windows VMs in the cloud. – jarmod Dec 03 '13 at 23:01
  • 2
    Tradeoff: create a network share on your machine and connect that share as a drive (from Explorer, Tools > Map a network drive), then add this drive to the list of drives you want accessible to the remote server. Only the files in this folder are then accessible to the remote server. – sleblanc Feb 17 '14 at 14:53
  • You should also make sure that you have no restrictions on the computer that you are remoting to by running Remote Desktop Services Manager or tsconfig.msc (or tscc.msc) on windows server. See @Nixphoe's answer on this [post](http://serverfault.com/questions/254530/tsclient-share-is-blank-when-rdping-to-remote-windows-server) – BornToCode May 05 '14 at 10:14
  • 1
    Rather than mapping a whole drive you can map a folder by creating a new drive letter using subst, e.g. subst p: C:\users\Example – eug Sep 17 '14 at 09:38
82

Ctrl + C at the Remote Desktop, and Ctrl + V at local, if you not looking for any automated solution. (Please check RD Config to enable copy and paste)

Raymond
  • 871
  • 6
  • 2
27

Once you have mapped the drives you want using mstsc, you can use \\tsclient to access the file system of the local machine i.e the Terminal services client from which you have RDP'ed on to the remote box.

If all you are trying to do is copy file from a remote box, just do \\machine\c$\path etc or share the folder and do \\machine\share to get them. RDP is not necessary in this case.

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • To use `\\tsclient` you have to select drives to bring into the RDP session first in the GUI I screenshotted. – Andy Arismendi Feb 16 '12 at 04:17
  • @AndyArismendi - Not when you are doing `\\tsclient\c` etc. tsclient is literal, not a placeholder for the machine. I will confirm, however. – manojlds Feb 16 '12 at 04:20
  • Just tried it... No worky unless I first select drives via the mstsc GUI. – Andy Arismendi Feb 16 '12 at 04:22
  • @AndyArismendi - It does seem to work only when the drives are mapped. Having my drives mapped always, I figured this wasn't needed. – manojlds Feb 16 '12 at 04:32
  • Would probably be a security hole if it always made your local drives accessible... I checked the mstsc flags and there's no option to map them via command line. – Andy Arismendi Feb 16 '12 at 04:34
  • @AndyArismendi - You can pass in a connection file to mstsc and specify redirect drives in it - http://coe.uncc.edu/mosaic/remote_desk/RDP%20File%20Settings.htm – manojlds Feb 16 '12 at 04:40
  • But that's too much work lol :-) Sure nuff `drivestoredirect:s:Local Disk (C:);RAID (E:);` – Andy Arismendi Feb 16 '12 at 04:45
12

Once you have mapped the needed drives as Andy says, you can execute remotely a LOCAL batch file every time you connect specifying it's local path (using \\tsclient\c to refer your local drive) in the Programs tab at RDP properties.
Remember to write cmd /c before that path.
The rdp connection will automatically close once the batch file ends, but you can add the pause command to the end to see what happened during execution.

Connecting this way, you can edit the batch file before connecting.

rdp execute BAT

Ivan Ferrer Villa
  • 2,129
  • 1
  • 26
  • 23
7

Make sure your remote Machine enabled PSRemoting by running the following command in PowerShell

Enable-PSRemoting –Force

From the client computer, run the following command to establish the connection.

net use "\\{RemoteIP}\c$" "{Password}" /USER:"{Username}" /persistent:no

Here after you can use Copy-Item, Delete-Item over the network.

Copy-Item [PACKAGEPATH]\* \\[COMPUTER]\c$\installers -recurse
Pang
  • 9,564
  • 146
  • 81
  • 122
Dasun
  • 3,244
  • 1
  • 29
  • 40
6
  1. In Client machine, Run->mstsc.exe-> Local Resources-> enable clipboard.
  2. In remote machine-> windows run command (Windows Key + R).
  3. Open cmd->(Taskkill.exe /im rdpclip.exe) type brackets command
  4. You got "Success", then
  5. Type same command prompt "rdpclip.exe"
  6. Now copy and paste both, its working fine
3

You can copy and paste files over RDP, it works perfectly. See http://www.reddit.com/r/sysadmin/comments/1d6a1o/til_you_can_copy_and_paste_files_over_rdp/ for more info.

boardtc
  • 1,304
  • 1
  • 15
  • 20
1

eug wrote what I thing is an extremely useful comment that seems to have overlooked by everyone:

You can very easily share a single folder by using subst to map it to a drive letter, and then selecting that drive in remote desktop.

Note that it's fairly easily to have problems with this method due to subst performing the mapping only for the user under which it is run.
So I recommend to run everything from a single command prompt:

  1. Open a command prompt (Win+R -> cmd)
  2. Type subst <lettertomap>: <pathtofolder>
  3. Type mstsc (which launches Remote Desktop)

Keep in mind that the subst mappings are not persistent across reboots, of course, so this is mostly convenient for a one-time session of file transfer.

There are actually also other ways to do the mapping, see raymond.cc .

And yes, the mapping does seem to disallow access to the rest of the drive, although I wouldn't bet my life that it doesn't have chroot-like "vulnerabilities" (assuming it is supposed to be secure in the first place).

gbr
  • 1,264
  • 8
  • 27
0

1) Install dropbox or equivalent cloud storage product and sync needed files that way between computers. Remember, you can allow only certain folders to be synced on specific devices (you don't have to sync the entire dropbox, just the folders you need)

2) If you are allowed to setup more than one user on the remote server, have a 2nd user and then have user2 session connect rdp session to user1. This will keep the user1's gui alive in the cloud without having to remain logged in to rdp locally.

This video should show you how to implement this 2 user setup on your server to hold an rdp session open. Note that this does 'permanently' use 1 rdp session until you decide to close it. [markdown cannot embed video :( ]

Then use AmmyyAdmin AnyDesk on user1's desktop to connect and manipulate the desktop. This includes using AnyDesk's file manager's ability to browse any folder you need and copy. AnyDesk can be free if you connect via direct IP connection. Most vps servers have dedicated IP addresss or subdomain address so this should not be a problem. Good idea to password protect your AnyDesk login and which IDs have access to unattended remote connections. The AnyDesk file manager is a bit crude, but it works. Their big thing is simplicity and speed.

Note: Use portable mode only on the remote user's desktop; Do NOT fully install AnyDesk. Also, the CPU usage might increase to stream the desktop screen, somewhat related to the size of the RDP window. I am using 1280 x 2048 window with 4 cores and the CPU usage is 22-25% idle or moving things around. This might decrease if there is more video ram or graphics processor on the target server. But, if you only "browse files" (use only the file manager without streaming the desktop), CPU usage >0.3% idle and >1 avg% when transferring files (burst up to 5-6% when the file is finished uploading and the pieces are being finalized).

You'd have to write your own scripts (java, .net, c#/c++, AutoIT, etc) to launch AnyDesk locally and automate the connecting and downloading specific files.

This strategy is a bit more complex, but it should do the job. Not sure why microsoft rdp cannot have some simple, quick file manager like what ammyy admin AnyDesk has; oh well.


Add: Can also use AnyDesk or Teamviewer. Teamviewer became a lot more restrictive on what is considered to be "non commercial use", but Anydesk is secure, much smaller footprint, and if you can have a direct connection doesn't seem to care too much about usage. If you do need a license, it will be much lighter on the wallet.

AnyDesk works flawlessly without any installation required. In fact, if using in a server environment as I described above, no installation is recommended.

Edit: AmmyyAdmin is no longer recommended for several months now due to some security and technical concerns. Added AutoIT as a scripting capability to automate interaction with GUI/nearly any windows function.

Jon Grah
  • 296
  • 2
  • 13
  • Not sure why people are downvoting without any comments. My solution does bypass the Admin's server restrictions AND has potential for a script-based solution to move files back and forth to the server. – Jon Grah Mar 21 '18 at 18:06
  • 1
    2019 and the AnyDesk solution still works perfectly for a similar problem. – Craig.Feied Mar 06 '19 at 19:35