vbs使用objShell.run运行程序

时间:2015-07-29 13:28:35

标签: vbscript

我有以下vbscript失败,最后一行出现错误

Option Explicit
Dim  objShell
Dim strComputer, strCmd , strVar
strComputer = "."
Set objShell = CreateObject("WScript.Shell")
' strVar = objShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
' strCmd = strVar & "\CaptureBites\Express\Programs\AutoBites\Autobites.exe"
' wscript.echo strCmd
objShell.Run "taskkill /im Autobites.exe",,True
WScript.Sleep(5000)
objShell.run """%ProgramFiles(x86)%""" &"\CaptureBites\Express\Programs\AutoBites\Autobites.exe"

问题是脚本打开文件夹%ProgramFiles(x86)%但不运行exe autobites.exe 你能帮我调试吗

1 个答案:

答案 0 :(得分:1)

必须引用整个文件规范,而不仅仅是第一部分:

objShell.run """%ProgramFiles(x86)%" &"\CaptureBites\Express\Programs\AutoBites\Autobites.exe"""