简体   繁体   English

如何通过VBScript操作命令行?

[英]How can I manipulate the command line through VBScript?

Could anyone give me example code to access the command line through VBScript? 谁能给我示例代码来通过VBScript访问命令行? I want to execute two commands respectively in a command prompt. 我想分别在命令提示符下执行两个命令。

For example, first command: cd C:\\a , second command: winzip32.exe -min -a D:\\d . 例如,第一个命令: cd C:\\a ,第二个命令: winzip32.exe -min -a D:\\d

you can use wshell.Run . 您可以使用wshell.Run The other one is wshell.exec 另一个是wshell.exec

Put your commands in a .cmd or .bat file and then run that. 将您的命令放在.cmd或.bat文件中,然后运行它。 You could even build the batch file inside your script if it is not static. 如果它不是静态的,甚至可以在脚本中构建批处理文件。

MyBatch.cmd MyBatch.cmd

CD C:\a
winzip32.exe -min -a D:\d

MyScript.vbs MyScript.vbs

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "MyBatch.cmd"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM