[英]Making a batch file wait until the shutdown command called by a Perl script (which is called by the batch file) gets executed
I have a batch file which calls a Perl script and then the Perl script which does some processing and then executes a command shutdown /r /t 1
. 我有一个批处理文件,该文件调用Perl脚本,然后调用Perl脚本进行一些处理,然后执行命令shutdown /r /t 1
。 In the batch file after the Perl is called, there is exit /b
. 在调用Perl之后的批处理文件中,存在/b
出口。 For instance: 例如:
Batch file: 批处理文件:
perl doSomething.pl
exit /b
Perl file: Perl文件:
do stuff
shutdown /r /t 1
I want the batch file to not exit and wait until the shutdown begins. 我希望批处理文件不退出并等待关闭开始。
I have tried 我努力了
start /wait perl dosomething.pl
and looping with tasklist to check for perl.exe
and exit only if perl.exe
process has finished. 并与任务列表循环以检查perl.exe
并仅在perl.exe
进程完成时退出。 Nothing worked. 没事。
Is there a solution to achieve this without 'sleeping' or infinite loop wait until shutdown? 是否有解决方案,而无需“休眠”或无限循环直到关机?
Well, that's strange. 好吧,这很奇怪。 It simply HAS to work with the last option, you've mentioned (checking the task list). 您已经提到过(检查任务列表),它只是可以使用最后一个选项。
However, the only option I can think of is to create a kind of flag file. 但是,我唯一想到的选择是创建一种标志文件。 Let your perl script create a file somewhere just before it terminates and make your bat loop around until this file is found and delete it before terminating. 让您的perl脚本在文件终止之前的某个位置创建一个文件,并使bat循环直到找到该文件,然后在终止之前将其删除。 To avoid "busy waiting" you could add something like ping localhost -n 6 >nul
inside your bat loop. 为了避免“忙碌等待”,您可以在bat循环中添加类似ping localhost -n 6 >nul
内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.