想让VBS程序 判断是否存在1.exe进程 没该进程就运行1.exe文件 有进程则不做操作退出脚本 要怎么写求代码

那么代码都无法启动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
第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追问

运行错误

追答

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

本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网