vbscript - How to run loop check vbs for particular running process? Or missing process? -


i running following vbscript (check.vbs):

set service = getobject ("winmgmts:")  each process in service.instancesof("win32_process")     if process.name = "cmd.exe"         wscript.echo "cmd running"         wscript.quit     end if next createobject("wscript.shell").run("c:\system\file.bat") 

this script check whether cmd.exe running or not. if running, script display message "cmd running". if not running, script open batch file c:\system\file.bat.

but need is: when run script check.vbs needs keep on checking until finds cmd.exe not running.

only if found cmd.exe not running needs run file.bat - after repeated checking in background (like loop program).

in simple words, when opening check.vbs script need continously check cmd.exe running or not, once found it's not running, need open file.bat.

still not sure if understand question correctly, assuming want monitor watches , re-spawns particular process this:

set wmi = getobject ("winmgmts://./root/civm2")  sub checkprocess(name, script)     each p in wmi.execquery("select * win32_process")         if p.name = name exit sub     next     createobject("wscript.shell").run script end sub      checkprocess "cmd.exe", "c:\system\file.bat"     wscript.sleep 100 loop 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -