从.BAT文件中,如何在知道驱动器号的情况下弹出U盘,例如尝试弹出e:
@echo off
rem What is this command?
EJECT e:
if errorlevel 1 goto could_not_eject
echo Success!
goto end
:could_not_eject
echo Unable to eject e:
goto end
:end
发布于 2020-04-02 01:58:37
尝试ejectjs.bat:
::to eject specific dive by letter
call ejectjs.bat G
::to eject all drives that can be ejected
call ejectjs.bat *
没有内置的命令可以做到这一点。
您也可以尝试使用powershell (它对我不起作用):
powershell和wmi class
powershell "(get-wmiobject -Class Win32_Volume | where{$_.DriveLetter -eq 'G:'}).Dismount($true,$false)"
或者wmic命令:
wmic path Win32_Volume where DriveLetter="G:" call Dismount
这对我不起作用。您也可以通过jscript使用wmi类,但我还没有尝试过。看起来只有调用动词解决方案才能正常工作。
https://stackoverflow.com/questions/60974265
复制相似问题