我想在关闭Netflix时关闭程序GOPHER.exe。我已经设置好了,当我打开Netflix时,GOPHER也会打开。现在,关闭GOPHER的.cmd文件中的命令是“TASKKILL / IM gopher.exe”。我想在关闭Netflix时运行它。
答案 0 :(得分:0)
它监视使用WMI退出的程序(MS的WBEM实现)。在这里它检查记事本是否退出并重新启动它。
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set objEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM Win32_ProcessStopTrace")
Do
Set objReceivedEvent = objEvents.NextEvent
msgbox objReceivedEvent.ProcessName
If lcase(objReceivedEvent.ProcessName) = lcase("Notepad.exe") then
Msgbox "Process exited with exit code " & objReceivedEvent.ExitStatus
WshShell.Run "c:\Windows\notepad.exe", 1, false
End If
Loop