在批处理文件中挂载 TrueCrypt 卷并等待其完成

在批处理文件中挂载 TrueCrypt 卷并等待其完成

我如何让批处理脚本等待 TrueCrypt 成功安装,然后再继续执行该脚本?

即,我想运行一个批处理脚本,该脚本将 a)挂载一个卷,b)等待用户输入正确的密码,c)在加密卷上运行一个程序

即,这些都不在我的批处理脚本中起作用:

truecrypt /vfile.tc /lx

start "" /b /wait truecrypt /vfile.tc /lx

start "" /wait /b truecrypt /vfile.tc /lx

start "" /wait /b batchWithTrueCryptMountCmds.bat

call schtasks /RUN /TN myTrueCryptTask

call truecrypt /vfiletc /lx

ETC。

有什么帮助吗?

答案1

如果你知道 TrueCrypt 驱动器号,那么可能如下所示:

:no
rem ping for pause (2 sec)
PING 127.0.0.1 -n 2 || PING ::1 -n 2

rem check drive is mounted
IF EXIST T:\ (GOTO yes) ELSE (GOTO no)
:yes

另请参阅http://www.robvanderwoude.com/wait.php了解在批处理文件中添加暂停的替代方法。您不一定需要暂停部分,但如果没有它,您最终会消耗比必要更多的 CPU 来检查驱动器是否已准备就绪。此处还讨论了:https://stackoverflow.com/questions/1672338/how-to-sleep-for-5-seconds-in-windowss-command-prompt-or-dos

检查此处讨论的驱动器:https://stackoverflow.com/questions/24060404/check-if-drive-letter-exists-in-batch-or-else-goto-another-piece-of-code

相关内容