如何更改批处理文件中的目录,然后在新目录中运行命令?我已经获得了更改目录的批处理文件,但不会运行该命令。它不是一个可执行文件,它是一个带有-options的文件。所以基本上我需要更改目录,然后运行一个保存在字符串中的命令。
发布于 2012-09-11 16:53:33
尝试使用
pushd yourdir
filetorun -options发布于 2012-09-11 14:35:20
我在下面给出了一个示例代码,用于更改目录并在此之后运行命令。
cd C:\ #Will change the directory to C:
ipconfig #Will return IP address details(any command can be used here)
pause #Will prevent command prompt from closing and waits for a keypress将其保存为批处理文件filename.bat,您将获得所需的输出。但是要确保输入的命令是正确的。
发布于 2012-09-11 14:19:33
"cd"代表"ChangeDirectory"。使用"cd"命令可以更改目录。
另请参阅:http://en.wikipedia.org/wiki/Cd_(command
干杯
https://stackoverflow.com/questions/12363620
复制相似问题