我正在创建一个bactch文件,该文件又需要在第二个窗口中创建并执行另一个bactch文件。我正在使用“start”命令,但在新窗口中,超时和ping等基本命令失败,因为无法识别。请注意,如果我从命令行开始但不在批处理文件中运行则没有任何问题,这只有在批处理文件中使用start时才会发生。有什么想法吗? :)
Btw o / s是Windows 7 Pro SP1 64位。
- 原始窗口 -
C:\mydir>start tmp.bat
- 新窗口 -
C:\mydir>c:
C:\mydir>cd \mydir
C:\mydir>echo Please wait for 60 seconds...
Please wait for 60 seconds...
C:\mydir>timeout 60
'timeout' is not recognized as an internal or external command,
operable program or batch file.
C:\mydir>ping 127.0.0.1
'ping' is not recognized as an internal or external command,
operable program or batch file.
- 完整批处理文件 -
set drive=c:
set path=\mydir
set tmpbatch=tmp.cmd
%drive%
cd %path%
echo %drive% > %tmpbatch%
echo cd %path% >> %tmpbatch%
echo echo Please wait for 60 seconds... >> %tmpbatch%
echo timeout 60 >> %tmpbatch%
echo copy config\topology.default.txt config\topology.txt >> %tmpbatch%
echo copy config\fasrc.default config\fasrc >> %tmpbatch%
echo echo demolive2^|localhost^|3^|demo^|Live Query Instance 2 for demo setup ^>^> config\topology.txt >> %tmpbatch%
echo bin\setup-cluster >> %tmpbatch%
echo findstr ERROR data\log\agent.log data\instances\deployment\log\kitchen.log >> %tmpbatch%
echo bin\capture-import demo demo\config\demo-config-capture.zip >> %tmpbatch%
echo bin\run-etl-job run.kjb "-DINSTANCE=demo" "-DTRIGGER=load-data" >> %tmpbatch%
echo bin\reindex demo >> %tmpbatch%
echo start "~\iexplore.exe" "http://localhost:8180/preview" >> %tmpbatch%
echo echo Please publish the configuration to the servers using File ^^^> File in the Business Manager >> %tmpbatch%
echo echo Press a key to continue once you have done that... >> %tmpbatch%
echo pause >> %tmpbatch%
echo bin\reindex demo >> %tmpbatch%
echo bin\fresh-index-to-live demo >> %tmpbatch%
echo echo All done! Check back for errors... >> %tmpbatch%
echo pause >> %tmpbatch%
echo del %tmpbatch% >> %tmpbatch%
start %tmpbatch%
bin\deployment-agent
答案 0 :(得分:3)
这是因为在您的完整批处理文件中,您正在重置PATH
变量,这是一个系统环境变量。我建议将名称更改为MYPATH
。