如何设置一个命令的工作目录在Windows批处理文件? [英] How to set the working directory of a command in a Windows batch file?
本文介绍了如何设置一个命令的工作目录在Windows批处理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说我有以下命令:
Let's say I have these commands:
Prog1.exe
D:\SomeDir\Prog2.exe
Prog3.exe
现在,说的第二行,我想将工作目录是D:\\ SomeDir,但在Prog1.exe和Prog3.exe我想默认工作目录(通常情况下,在我的.bat文件是)。如果我试试这个
Now, say for the second line, I would like the working directory to be D:\SomeDir, but in Prog1.exe and Prog3.exe I want the default working directory (normally, where my .bat file is). If I try this
Prog1.exe
cd D:\SomeDir
D:\SomeDir\Prog2.exe
Prog3.exe
显然PROG3将在SomeDir被执行,这不是我想要的。
Apparently Prog3 will be executed in SomeDir, which is not what I want.
推荐答案
您可以使用pushd / POPD命令(与帮助 PUSHD /?
)
You could use the pushd/popd commands (help with pushd /?
)
Prog1.exe
Pushd D:\SomeDir
Prog2.exe
popd
Prog3.exe
这篇关于如何设置一个命令的工作目录在Windows批处理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文