我正在运行一个批处理文件
cd desktop
net use z: \\NETWORKCOMPUTER1-PC\i
z:
cd movies
dir > c:movies.txt
cd ..\shows
dir > c:shows.txt
cd ..\anime
dir > c:anime.txt
net use z: /delete
最后它给出了这样的消息:
"There are open files and/or incomplete directory searches pending on the connection to z:.
Is it OK to continue disconnecting and force them closed? (Y/N) [N]:"
此时我选择“N”并且所有文本文件都已正确创建。
如何使其在完成创建最后一个文本文件之前不删除网络连接?
已解决 - 在删除 z: 网络连接之前需要切换回 c:。
最佳答案
这是因为您将 z:
设置为脚本顶部附近的当前驱动器。
因此,为了避免出现该消息,请在尝试删除 z:
映射之前将当前驱动器设置为 c:
(或您希望的任何其他驱动器)。
例如,像这样:
NET USE Z: \\ComputerName\FolderShare
Z:
REM Do some stuff here with files/folders on Z:
REM Change current drive to C: before removing the network drive.
C:
NET USE Z: /DELETE
关于batch-file - 批处理文件调用命令未在下一个命令之前完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28325313/