Batch file bat文件在VirtualBox中不工作
我的蝙蝠档案Batch file bat文件在VirtualBox中不工作,batch-file,virtualbox,Batch File,Virtualbox,我的蝙蝠档案 @echo off :loop tasklist /fi "pid eq 788" | find ":" > nul if errorlevel 1 ( ping 127.0.0.1 -n 2 goto loop ) else ( goto continue ) :continue del "Run.exe" ren latest.exe "Run.exe" start "" "Run.exe" start /b " cmd /c del "%~f0"&
@echo off
:loop
tasklist /fi "pid eq 788" | find ":" > nul
if errorlevel 1 (
ping 127.0.0.1 -n 2
goto loop
) else (
goto continue
)
:continue
del "Run.exe"
ren latest.exe "Run.exe"
start "" "Run.exe"
start /b " cmd /c del "%~f0"&exit /b
如果文件是在主PC Windows 8.1上执行的,它可以正常工作,没有任何错误,但如果我尝试在VirtualBox Windows XP上运行它,它将不工作
获取错误“没有使用指定条件运行的任务”
知道为什么不在VM中工作吗?这是因为您没有运行PID为
788
的任何任务。关于PID需要注意的一点是,它们是随机分配的,同一个程序通常在每次运行时都有不同的PID。IE:第一次运行MyProgram.exe时,它接收到的PID为
1479
,第二次为1876
,依此类推。编辑:除了几乎总是在
1000下有PID的系统程序之外。而系统空闲进程
的PID为0
,以及系统中断
没有PID(-
)。你怎么想,pid=788的任务必须存在吗?很幸运它能在windows 8上运行。这段代码是我目前正在尝试实现的更大的AutoIT代码的一部分。