且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MS Batch:检查驱动器是否在使用中

更新时间:2023-11-28 09:41:28

使用 IF EXIST IF NOT EXIST 组合:

:FindDrive
if exist Z:\nul goto Mounted
timeout /T 5
goto FindDrive
:Mounted

NUL是每个文件夹中都存在的虚拟"文件.因此,如果c:\ anypath \ nul存在,则驱动器存在.

NUL is the a 'virtual' file that exists in every folder. So if c:\anypath\nul exists, the drive exists.