![](/img/trans.png)
[英]How to copy the file from one windows machine to another windows machine in a particular drive using batch script?
[英]How to copy a file from a USB drive to C drive in Windows 10 using a batch file?
我在USB驅動器中有一些文件需要復制到多台計算機。 這些文件包含將使用其他配置文件的可執行文件。 我的問題是,對於Windows 10 PC,在創建temp_folder時,沒有文件被復制。
對於Windows 7,我能夠創建一個批處理文件,該文件將文件復制到本地驅動器並使用配置文件運行可執行文件。
批處理文件的內容如下:
mkdir C:\temp_installer
copy ".\file_name" "C:\temp_installer"
<rest of the code>
我曾嘗試使用xcopy和robocopy,但仍看到批處理文件正在運行,只是停止創建該文件夾。 Windows 7中未觀察到相同的問題。
有人嘗試過此方法還是可以告訴我我可能做錯了什么?
這將是一個更好的選擇,我們不需要在C:
根目錄上的權限問題上感到費解C:
@echo off
cd /d "%~dp0"
set "inst_dir=%temp%\temp_installer"
mkdir "%inst_dir%">nul 2>&1
for %%i in (*) do if not "%%i"=="%~nx0" copy /Y "%%i "%inst_dir%"
:# When completed, we can call execute the files from "%inst_dir%"
老實說,不需要for
循環,我只是這樣做是為了不將.bat
/ .cmd
文件本身復制到該文件夾中,因為那里不需要它。
甚至更簡單,而不必執行上述所有操作,您可以使用robocopy
@echo off
cd /d "%~dp0"
robocopy /MIR .\ "%temp%\temp_installer"
Powershell是您的朋友在這里,請嘗試以下操作:
Copy-Item E:\Document\ C:\Temp\Document\ -R
對我來說效果很好,它甚至可以創建目標目錄, Copy-Item
也具有alias
cp
和copy
。
如果運行某種腳本,則Execution-Policy
可能會出現問題: https : //docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.security/set-executionpolicy?view= Execution-Policy
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.