我是vbs的菜鸟,这是一个脚本(来自How to run a file on background using vbscript with launch options)。但是运行不起作用。
Option Explicit
Dim wshShell
Set WshShell = CreateObject("WScript.Shell")
Function qq(s) : qq = """" & s & """" : End Function
Sub mapF(a, f)
Dim i
For i = LBound(a) To UBound(a)
a(i) = f(a(i))
Next
End Sub
Dim sFSpec : sFSpec = "C:\Program Files\Pineapplesoft\Lost computer\lostcomputeraudio.bat"
Dim aParms : aParms = Split("1#/pi:pa po#last parm", "#")
mapF aParms, GetRef("qq")
Dim sCmd : sCmd = Join(Array( _
qq(sFSpec) _
, Join(aParms) _
))
WshShell.Run qq(sCmd)
答案 0 :(得分:2)
qq(sCmd)正在返回 "" C:\ Program Files \ Pineapplesoft \ Lost computer \ lostcomputeraudio.bat" " 1" " / pi:pa po" "最后一个""
你想要的 " C:\ Program Files \ Pineapplesoft \ Lost computer \ lostcomputeraudio.bat" " 1" " / pi:pa po" "最后一个"
删除qq(sCmd)函数,它应该可以工作。
Option Explicit
Dim wshShell
Set WshShell = CreateObject("WScript.Shell")
Function qq(s) : qq = """" & s & """" : End Function
Sub mapF(a, f)
Dim i
For i = LBound(a) To UBound(a)
a(i) = f(a(i))
Next
End Sub
Dim sFSpec : sFSpec = "C:\Program Files\Pineapplesoft\Lost computer\lostcomputeraudio.bat"
Dim aParms : aParms = Split("1#/pi:pa po#last parm", "#")
mapF aParms, GetRef("qq")
Dim sCmd : sCmd = Join(Array( _
qq(sFSpec) _
, Join(aParms) _
))
wshShell.Run sCmd
答案 1 :(得分:-1)
您可以像这样运行Cmd
Set shell=CreateObject
Shell.Run("cmd.exe")