很难用这个。我可以成功地从命令提示符运行以下命令,但无法使用VB脚本。
来自CMD:
我在VBS尝试过的事情:
Dim objShell, strPath1, strAttr, strPath2
Set objShell = CreateObject ("WScript.Shell")
strPath1 = "C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"
strAttr1 = " -T ws start "
strAttr2 = "C:\Users\Office\Documents\Virtual Machines\Windows 7\Windows 7.vmx"
strAttr3 = " nogui"
'WScript.Echo strPath1 & strAttr1 & """" & strAttr2 & """" & strAttr3
objShell.Run strPath1 & strAttr1 & """" & strAttr2 & """" & strAttr3
我得到的错误是:系统找不到指定的文件。
答案 0 :(得分:2)
工作守则最终成为:
Dim objShell, strPath1, strAttr1, strAttr2, strAttr3
Set objShell = CreateObject ("WScript.Shell")
strPath1 = """C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"""
strAttr1 = " -T ws start "
strAttr2 = """C:\Users\Office\Documents\Virtual Machines\Windows 7\Windows 7.vmx"""
strAttr3 = " nogui"
objShell.Run strPath1 & strAttr1 & strAttr2 & strAttr3
答案 1 :(得分:0)
我将替换objShell.Run strPath1 & strAttr1 & """" & strAttr2 & """" & strAttr3
与
objShell.Run strPath1 & strAttr1 & chr(34) & strAttr2 & chr(34) & strAttr3
或在chr(34)
变量前后添加strAttr2
strAttr2 = chr(34) & "C:\Users\Office\Documents\Virtual Machines\Windows 7\Windows 7.vmx" & chr(34)
btw chr(34) = "