那么代码都无法启动Program Files下的文件啊 是不是VBS程序都不能打开这文件夹里面的文件?
第1个回答 2012-03-16
Set prow = GetObject("winmgmts:\\" & strComputer).InstancesOf("Win32_Process")
set shell=createobject("wscript.shell")
Public Function Prpath(ByVal Val)
For Each i In prow
If LCase(i.Name) = LCase(Val) Then
Prpath = Prpath + 1
End If
Next
End Function
if prpath("1.exe")<1 then shell.run "1.exe路径" else wscript.quit
set shell=createobject("wscript.shell")
Public Function Prpath(ByVal Val)
For Each i In prow
If LCase(i.Name) = LCase(Val) Then
Prpath = Prpath + 1
End If
Next
End Function
if prpath("1.exe")<1 then shell.run "1.exe路径" else wscript.quit
第2个回答 2012-03-16
Set wsh=createobject("wscript.shell")
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
name = "1.exe"
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_process where name='"&name&"'")
If wmiObjects.count=0 then
wsh.Run "D:\1.exe" '这里写1.exe的路径
End If追问
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
name = "1.exe"
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_process where name='"&name&"'")
If wmiObjects.count=0 then
wsh.Run "D:\1.exe" '这里写1.exe的路径
End If追问
运行错误
追答Dim wsh,name '开始少了这句
Set wsh=createobject("wscript.shell")
Set wmiService = GetObject("winmgmts:\\.\root\cimv2")
name = "1.exe"
Set wmiObjects = wmiService.ExecQuery("SELECT * FROM Win32_process where name='"&name&"'")
If wmiObjects.count=0 then
wsh.Run "D:\1.exe" '这里写1.exe的路径
End If