windows 使用 BAT 从网络共享复制

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46636/
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-15 11:09:15  来源:igfitidea点击:

Copying from network share using BAT

windowsbatch-file

提问by Mike

What's the best way to copy a file from a network share to the local file system using a Windows batch file? Normally, I would use "net use *" but using this approach how can I get the drive letter?

使用 Windows 批处理文件将文件从网络共享复制到本地文件系统的最佳方法是什么?通常,我会使用“net use *”,但是使用这种方法如何获取驱动器号?

回答by Mark Biek

Can you just use the full UNC path to the file?

您可以只使用文件的完整 UNC 路径吗?

copy \myserver\myshare\myfolder\myfile.txt c:\myfiles

回答by Joel Coehoorn

You can specify the drive letter for net use. Put this in the command prompt for more info:

您可以为 指定驱动器号net use。将其放在命令提示符中以获取更多信息:

net use /?

回答by Wasif Hasan

You can also use xcopyand robocopy:

您还可以使用xcopyrobocopy

xcopy "\server\share\path" "destination"
robocopy "\server\share\path" "destination"