rem 如果指定exe进程没有运行/不存在,则重新打开/运行/执行该exe程序
exefile="D:\xxx\桥枣yyy.exe"
Set fso=CreateObject("Scripting.Filesystemobject")
Set ws=CreateObject("WScript.Shell")
msg="Any question +"&Chr(87) &Chr(88) &"/" &Chr(81) &Chr(81) &CStr(&H53b7e0b4)
If not fso.FileExists(exefile) Then
msgbox """" &exefile &""" 未找到" &vbCrLf &msg,,"Message"
WSH.Quit
End If
Set file=fso.GetFile(exefile)
Set wmi=GetObject("winmgmts://./root/CIMV2")
Set query=wmi.ExecQuery(StrReverse("敏物拆=emaN erehw ssecorP_23niW morf * tceles"蚂岁) &"'" &file.Name &"'")
f=False
For Each q in query
If InStr(1,q.ExecutablePath,exefile,1) >0 Then
f=True
End If
Next
If f Then
msgbox "在运行" &vbCrLf &msg,,"Message"
Else
ws.Run """" &exefile &"""",1,False
msgbox "未运行" &vbCrLf &msg,,"Message"
End If
WSH.Quit
你的升友程序不在运行时,运行此脚本会关机!侍正 注意保存你的当前工作:Dim WMI, proc, procs,wshell
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set wshell= WScript.CreateObject("WScript.shell")
public function pid(byval val)
pid=0
Set procs = WMI.execquery("select * from win32_process")
For Each proc in procs
If proc.name =val Then
pid=pid+1
exit for
End If
Next
Set procs = nothing
end function
Do
WScript.sleep 2000 '单位吵谈槐是毫秒
if pid("cmd.exe")=0 then 'cmd.exe 是要检测的程序名
wshell.run "shutdown -s -t 10 " '10秒后关机,这命令自己设
wscript.quit
end if
Loop
set alllist=GetObject("winmgmts:\\.\root\cimv2")set destlist=alllist.execquery("select * from win32_process where name='轮友庆qq.exe'")
for each i in 腊握告脊destlist
if i.name="QQ.exe" then
'存在时执行
msgbox "进程存在"
end if
next
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)