将文件从远程 RDP 复制到本地机器

有没有办法可以启动 RDP 会话到远程 Windows 服务器,并执行文件传输到本地计算机?远程 WindowsServer 的版本各不相同。范围从2000年到2008年。

我试图寻找解决方案,但似乎到处都是。一些人建议使用 mstsc.exe,另一些人建议使用 PowerShell/Java/ASP Net。我很困惑。感谢你的指导。

谢谢!

以下更新: 2012年2月17日

谢谢你的建议。要添加的远程服务器是安全锁定的,我不允许安装 SSH 服务器,FTP 服务器,或共享驱动器。访问远程计算机的唯一方法是通过 RDP,而且这些计算机也位于单独的 VLAN 上,只有获得授权的用户才能使用 RDP 访问这些计算机。我正在尝试创建一个脚本,可以帮助授权用户下载所需的文件。

314753 次浏览

You can map a drive using remote desktop.

Options > Local Resources > More

enter image description here

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.

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

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)

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.

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.

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
  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

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).