我有一个像这样的Visual Basic脚本:
Set WshShell = CreateObject("Wscript.Shell") WshShell.Run " cmd.exe", 8, True
运行它给了这个错误:
--------------------------- Windows脚本主机 --------------------------- 脚本:D:\ Folder \ MyScript.vbs 线路:2 Char:1 错误:无法等待进程。 代码:80020009 来源:WshShell.Run --------------------------- 好 ---------------------------
我确实打开了一个浏览器窗口。
为什么是这样?
该命令以空格(或vbTab
)开头。 只是修剪它,一切都会好的。
尝试像这样:
Set WshShell = CreateObject("Wscript.Shell") WshShell.Run "cmd /k",1,True
或者像这样的东西:
Set WshShell = CreateObject("Wscript.Shell") Command = "Ipconfig /all" WshShell.Run "cmd /k " & Command & "",1,True