[英]How can I execute consecutive commands from a command prompt?
How can I execute two consecutive commands on the command line with the help of wshshell.exec
or wshshell.run
in vbscript? 如何在vbscript中的
wshshell.exec
或wshshell.run
的帮助下在命令行上执行两个连续的命令? For example I need to execute cd C:\\a
and then winzip32.exe -min -a D:\\a
. 例如,我需要执行
cd C:\\a
然后执行winzip32.exe -min -a D:\\a
。
You can do something like cd C:\\a & winzip32.exe -min -a D:\\a
where the &
separates commands so the that second one runs once the first has finished successfully. 您可以执行
cd C:\\a & winzip32.exe -min -a D:\\a
,其中&
分隔命令,以便第二个命令在第一个命令成功完成后运行。 For example, you could run it like this: 例如,您可以这样运行它:
Set oExec = WshShell.Exec("cmd /c cd C:\a & winzip32.exe -min -a D:\a")
Without the cmd /c
in the beginning, you can't do things like cd
because cmd.exe is responsible for processing the cd
and &
. 开始时没有
cmd /c
,您将无法执行cd
因为cmd.exe负责处理cd
和&
。
根据您的操作,可以使用WshShell.Exec“ c:\\ a \\ winzip32.exe -min -a D:\\ a”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.