使用cli删除usb驱动器,成功删除关闭窗口

时间:2015-06-22 11:42:07

标签: windows batch-file

我想知道制作一个有这样意图的批处理文件:

当我的笔记本电脑上弹出的USB驱动器成功卸载时,我想让我的窗户关闭。

所以,我使用RemoveDrive

假设我将闪存驱动器安装到E,我使用此命令

M(isnan(M)) = 0;

它给了我这样的信息:

RemoveDrive.exe E: -L

现在,我想知道制作批处理文件(.bat),成功时,它会执行'shutdown / s'。如果失败,它只给我一个消息错误。怎么会 ? 艾米帮助它如此欣赏。

编辑: 基于此网站:FAQ 它说:

Removing 'My drive'(E:)
success

所以这是我目前的代码:

0 - successfully removed a device
1 - device identified but not removed
2 - device not found or parameters are invalid
4 - RemoveDrive.exe located on the drive to remove -> temporary copy 
    created and executed

如果成功或失败,它仍然给我命令的语法是不正确的消息

1 个答案:

答案 0 :(得分:0)

根据Command-Line Reference中的if命令语法和说明:

if %ERRORLEVEL% == def (
  shutdown /s
) else (
  echo 'Something have problem'
)