Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file bat文件在VirtualBox中不工作_Batch File_Virtualbox - Fatal编程技术网

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代码的一部分。