从另一个批处理文件运行一个批处理文件
我想从批处理文件 2(C:) 运行批处理文件 1(路径 C:\3rdparty\Test\App) VS2008.sln 位于 C:\3rdparty\Test\App\VS2008
批处理文件 1
REM BatchFile1.bat
set DEVENV_PATH=%VS90COMNTOOLS%..\IDE
REM ---------------------------------------------------------------------
set OUTDIR=.\output\windows\x86
rmdir /S /Q %OUTDIR%
mkdir %OUTDIR%
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Release|Win32"
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Debug|Win32"
REM ---------------------------------------------------------------------
set OUTDIR=.\output\windows\x64
rmdir /S /Q %OUTDIR%
mkdir %OUTDIR%
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Release|x64"
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Debug|x64"
REM ---------------------------------------------------------------------
echo "BatchFile1.bat completed."
批处理文件 2
echo "Running Batch File 2"
call C:\3rdparty\Test\App\BatchFile1.bat
此处,当从 Batchfile2 调用批处理文件 1 时,由于路径不同,因此无法执行 VS2008.sln。 我不想更改批处理文件 1。是否可以更改批处理文件 2 来执行批处理文件 1。
I want to run Batch file 1(Path C:\3rdparty\Test\App) from Batch file 2(C:)
and VS2008.sln is there in C:\3rdparty\Test\App\VS2008
Batch File 1
REM BatchFile1.bat
set DEVENV_PATH=%VS90COMNTOOLS%..\IDE
REM ---------------------------------------------------------------------
set OUTDIR=.\output\windows\x86
rmdir /S /Q %OUTDIR%
mkdir %OUTDIR%
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Release|Win32"
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Debug|Win32"
REM ---------------------------------------------------------------------
set OUTDIR=.\output\windows\x64
rmdir /S /Q %OUTDIR%
mkdir %OUTDIR%
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Release|x64"
call "%DEVENV_PATH%\devenv.com" VS2008\VS2008.sln /Rebuild "Debug|x64"
REM ---------------------------------------------------------------------
echo "BatchFile1.bat completed."
Batch File 2
echo "Running Batch File 2"
call C:\3rdparty\Test\App\BatchFile1.bat
Here when batchfile1 is called from Batchfile2 it is not able to execute VS2008.sln since path is different.
I Don't want to change batchfile1.Is it possible to do changes in batch file 2 to execute the Batch file1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将目录更改为 BatchFile1 的目录。
Try changing the directory to the directory of BatchFile1.
我已在脚本中添加了一个本地变量,该变量设置为 BatchFile1 路径(无论它是什么),因此现在您可以使用相对于 BatchFile1 路径的路径。
I've added a local variable to your script that is set to the BatchFile1 path, whatever it is, so now you can use path relative to the BatchFile1 path.
您可以将
这
代码放在batchfile1.bat中,
会将当前目录更改为batchfile1所在的位置,然后在完成后更改回来
You could put
and
around your code in batchfile1.bat
which would change the current directory to wherever batchfile1 is and then change back when you've done