windows 将文件从远程 RDP 复制到本地计算机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9304953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:14:16  来源:igfitidea点击:

Copy Files from Remote RDP to Local Machine

windowspowershell

提问by louis xie

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.

有没有办法可以启动到远程 Windows 服务器的 RDP 会话,并执行到本地计算机的文件传输?远程 Windows Server 的版本各不相同。范围从 2000 年到 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.

我试图查找解决方案,但似乎到处都是。有些建议使用 mstsc.exe,有​​些建议使用 PowerShell / Java / ASP Net。我糊涂了。感谢这里的一些指导。

Thanks!

谢谢!

Update Below: 17 Feb 2012

以下更新:2012 年 2 月 17 日

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.

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

回答by Andy Arismendi

You can map a drive using remote desktop.

您可以使用远程桌面映射驱动器。

Options > Local Resources > More

选项 > 本地资源 > 更多

enter image description here

在此处输入图片说明

回答by Raymond

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)

如果您不寻找任何自动化解决方案,请在远程桌面按 Ctrl + C,在本地按 Ctrl + V。(请检查 RD 配置以启用复制和粘贴)

回答by manojlds

Once you have mapped the drives you want using mstsc, you can use \\tsclientto 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.

一旦您使用 mstsc 映射了您想要的驱动器,您就可以使用它\\tsclient来访问本地机器的文件系统,即您从其 RDP 连接到远程机器的终端服务客户端。

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

如果您要做的只是从远程框中复制文件,只需执行\\machine\c$\pathetc 或共享文件夹并执行\\machine\share即可获取它们。在这种情况下不需要 RDP。

回答by Ivan Ferrer Villa

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

一旦您按照安迪所说的那样映射了所需的驱动器,您就可以在每次连接时远程执行本地批处理文件\\tsclient\c,并在 RDP 属性的“程序”选项卡中指定它的本地路径(用于引用您的本地驱动器)。
记得在那个路径之前写cmd /c
一旦批处理文件结束,rdp 连接将自动关闭,但您可以将pause命令添加到末尾以查看执行过程中发生了什么。

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

通过这种方式连接,您可以在连接前编辑批处理文件。

rdp execute BAT

rdp 执行 BAT

回答by Dasun

Make sure your remote Machine enabled PSRemoting by running follwing command in powershell

通过在 powershell 中运行以下命令确保您的远程机器启用了 PSRemoting

Enable-PSRemoting –Force

From the client computer run 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、Delete-Item。

Copy-Item [PACKAGEPATH]\* \[COMPUTER]\c$\installers -recurse

回答by boardtc

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.

您可以通过 RDP 复制和粘贴文件,它可以完美运行。有关更多信息,请参阅http://www.reddit.com/r/sysadmin/comments/1d6a1o/til_you_can_copy_and_paste_files_over_rdp/

回答by Raghulraj Palanisamy

  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
  1. 在客户端机器上,运行->mstsc.exe-> 本地资源-> 启用剪贴板。
  2. 在远程机器-> windows 运行命令(Windows 键 + R)。
  3. 打开cmd->(Taskkill.exe /im rdpclip.exe) 输入括号命令
  4. 你得到了“成功”,然后
  5. 键入相同的命令提示符“rdpclip.exe”
  6. 现在复制并粘贴两者,它工作正常

回答by gbr

eugwrote what I thing is an extremely useful commentthat seems to have overlooked by everyone:

eug写的我的东西是一个非常有用的评论,似乎被所有人忽视了:

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

您可以非常轻松地共享单个文件夹,方法subst是将其映射到驱动器号,然后在远程桌面中选择该驱动器。

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

请注意,由于subst仅为运行它的用户执行映射,因此使用此方法很容易出现问题。
所以我建议从单个命令提示符运行所有内容:

  1. Open a command prompt (Win+R -> cmd)
  2. Type subst <lettertomap>: <pathtofolder>
  3. Type mstsc(which launches Remote Desktop)
  1. 打开命令提示符(Win+R -> cmd)
  2. 类型 subst <lettertomap>: <pathtofolder>
  3. 类型mstsc(启动远程桌面)

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

请记住,subst映射在重新启动后不是持久的,因此这对于文件传输的一次性会话最方便。

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

实际上还有其他方法可以进行映射,请参阅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).

是的,映射似乎不允许访问驱动器的其余部分,尽管我不会打赌它没有类似 chroot 的“漏洞”(假设它首先应该是安全的) .

回答by Jon Grah

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)

1) 安装 dropbox 或等效的云存储产品并在计算机之间以这种方式同步所需的文件。请记住,您可以只允许在特定设备上同步某些文件夹(您不必同步整个 Dropbox,只需同步您需要的文件夹)

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.

2) 如果允许您在远程服务器上设置多个用户,请设置第二个用户,然后让 user2 会话将 rdp 会话连接到 user1。这将使用户 1 的 gui 在云中保持活动状态,而无需在本地保持登录到 rdp。

This videoshould 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 :( ]

该视频应向您展示如何在您的服务器上实现这 2 个用户设置以保持 rdp 会话打开。请注意,这会“永久”使用 1 个 rdp 会话,直到您决定关闭它。[markdown 不能嵌入视频 :( ]

Then use AmmyyAdminAnyDeskon 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.

然后在用户 1 的桌面上使用AmmyyAdmin AnyDesk连接和操作桌面。这包括使用 AnyDesk 的文件管理器浏览您需要和复制的任何文件夹的功能。如果您通过直接 IP 连接进行连接,AnyDesk 可以是免费的。大多数 vps 服务器都有专用的 IP 地址或子域地址,所以这应该不是问题。用密码保护您的 AnyDesk 登录名以及哪些 ID 可以访问无人值守远程连接的好主意。AnyDesk 文件管理器有点粗糙,但它有效。他们最重要的是简单和速度。

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

注意:仅在远程用户的桌面上使用便携模式;不要完全安装 AnyDesk。此外,CPU 使用率可能会增加以流式传输桌面屏幕,这与 RDP 窗口的大小有些相关。我正在使用 1280 x 2048 窗口和 4 核,CPU 使用率是 22-25% 空闲或四处移动。如果目标服务器上有更多的视频内存或图形处理器,这可能会减少。但是,如果您只“浏览文件”(仅使用文件管理器而不流式传输桌面),则传输文件时 CPU 使用率 >0.3% 空闲和 >1 avg%(文件上传完成后高达 5-6%,并且作品正在敲定)。

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.

您必须编写自己的脚本(java、.net、c#/c++、AutoIT等)才能在本地启动 AnyDesk 并自动连接和下载特定文件。

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 adminAnyDesk has; oh well.

这个策略有点复杂,但它应该可以完成这项工作。不知道为什么 microsoft rdp 不能像ammyy adminAnyDesk那样有一些简单、快速的文件管理器;那好吧。



Add: Can also use AnyDeskor 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或 Teamviewer。Teamviewer 在什么被认为是“非商业用途”方面变得更加严格,但 Anydesk 是安全的,占用空间小得多,如果您可以直接连接,似乎不太关心使用情况。如果您确实需要许可证,则钱包上的费用会轻得多。

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

AnyDesk 无需任何安装即可完美运行。事实上,如果在我上面描述的服务器环境中使用,则不建议安装。

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.

编辑:由于一些安全和技术问题,现在几个月不再推荐 AmmyyAdmin。添加了 AutoIT 作为脚本功能,以自动与 GUI/几乎任何 Windows 功能进行交互。