VBS判断进程运行

2024-12-18 20:48:01
推荐回答(1个)
回答1:

这个容易Set objShell = CreateObject("Wscript.Shell")
objshell.run """C:\DOWN.exe"""
Do
Set wmi=GetObject("winmgmts:\\.\root\cimv2")
Set list=wmi.ExecQuery("select * from win32_process where name='DOWN.exe'")
If list.count=0 Then '中间加个判断DOWN.exe进程是否停止,如果停止就运行下面的代码
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
set c=fso.getfile("C:\a.txt")
c.copy("E:\a.txt")
End If
WScript.Sleep 2000
loop