Windows VBScript

Example: monitor the process running or not, if not, run it.

1.bat
start 1.vbs

1.vbs
on error resume next
'monitor the process running or not

set y=getobject("winmgmts:\\.\root\cimv2")
set ws=createobject("wscript.shell")
set x=y.execquery("select * from win32_process where name='notepad.exe'") 
for each i in x
     wscript.quit
     'msgbox "notepad.exe is running"
next

'run the process
'msgbox "notepad.exe is not running"
ws.run "C:\windows\system32\notepad.exe"

Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error