Vbscript 如何使用WShell.run运行多个dos命令
我的用例是在vbscript中模拟dos命令Vbscript 如何使用WShell.run运行多个dos命令,vbscript,cmd,Vbscript,Cmd,我的用例是在vbscript中模拟dos命令 cmd CD C:/ cmd Dir cmd echo Error Code=%ErrorLevel% >> c:\error.txt 我可以写vbscript代码直到cmd Dir,但不知道如何在单个vbscript代码中模拟错误代码 Dim oShell Set oShell = WScript.CreateObject ("WScript.Shell") oShell.run "cmd /K CD C:\ & Dir" S
cmd CD C:/
cmd Dir
cmd echo Error Code=%ErrorLevel% >> c:\error.txt
我可以写vbscript代码直到cmd Dir,但不知道如何在单个vbscript代码中模拟错误代码
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "cmd /K CD C:\ & Dir"
Set oShell = Nothing
将命令放入批处理文件中,然后运行该文件 YourBatch.cmd
CD C:/
Dir
echo Error Code=%ErrorLevel% >> c:\error.txt
然后,在VBscript中调用批处理文件
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "YourBatch.cmd"
Set oShell = Nothing
您好,aphoria,我不能在vbscript中执行此操作吗?您的另一个选项是执行您所做的操作,并使用
&
或&
链接命令。