使用vbs脚本�监控windows�务器上的应用程��存在就�动)


¡¡¡¡±¾ÎıêÇ©£ºvbs守å�«è¿›ç¨‹,监控进程

这个vbs代�主�实现的功能就是�行该程�,就会在进程中出现一个wscript.exe 它会�隔10s扫�一次进程中是�存在notepad.exe这个程�,�存在就�动。这个�动程��能跟进程��一样,好比tomcat应用,�动的是startup.bat,��进程�为java.exe,这样就需�调整代�proname="java.exe"

关于如果关掉监控 �以在�行下执行taskkill /f /im wscript.exe 或者在任务管��进程中找到wscript.exe 结�进程就�以了

调整WshShell.Run("startup.bat")

核心代�

dim wmi,proc,procs,proname,flag,WshShell
Do
proname="notepadjb51.exe" '需�监测的�务进程的�称,自行替�这里的记事本进程�
set wmi=getobject("winmgmts:{impersonationlevel=impersonate}!.rootcimv2")
set procs=wmi.execquery("select * from win32_process")
flag=true
for each proc in procs
if strcomp(proc.name,proname)=0 then
flag=false
exit for
end if
next
set wmi=nothing
if flag then
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run ("notepadjb51.exe")
end if
wscript.sleep 10000 '检测间隔时

VBS写个�脚�实时监测指定程�是��行 对�行的软件进行�作 最�关闭�行软�/h3>
strComputer = "."
Set objShell = CreateObject("Wscript.Shell") 
do
Set wbemServices = Getobject("winmgmts:\" & strComputer)
Set wbemObjectSet = wbemServices.InstancesOf("Win32_process")
For Each wbemObject In wbemObjectSet
if wbemObject.name="QQ.exe" then
  WScript.Sleep 1000
  objShell.SendKeys "{F12}"
  WScript.Sleep 1000
  objShell.SendKeys "{ENTER}"
  dim WSHshell 
  set WSHshell = wscript.createobject("wscript.shell") 
  WSHshell.run "taskkill /im wscript.exe /f ",0 ,true 
end if
Next
loop

批处�检测进程是�存在;这个我用�检测文化进程是�存在,因为是绿色版的,很容易被关闭,所以需�检测�/h3>
tasklist /nh|find /i "ClientOfWatcher.exe"
if ERRORLEVEL 1 (start C:watcherClientOfWatcher.exe) else (exit)

VBS定时检测进程是�存在,如果�存在就�动进程�/h3>
option Explicit    
dim wmi,proc,procs,proname,flag,WshShell    
Do  
    proname="ClientOfWatcher.exe" '需�监测的�务进程的�称,自行替�这里的记事本进程�   
set wmi=getobject("winmgmts:{impersonationlevel=impersonate}!\.
ootcimv2")    
set procs=wmi.execquery("select * from win32_process")    
  flag=true    
for each proc in procs    
    if strcomp(proc.name,proname)=0 then    
      flag=false    
      exit for    
    end if    
next    
  set wmi=nothing    
  if flag then    
    Set WshShell = Wscript.CreateObject("Wscript.Shell")    
    WshShell.Run ("C:WatcherClientOfWatcher.exe")    
end if    
  wscript.sleep 50000 '检测间隔时间,这里�0�   
loop

关于vbs系统�行�,系统进程中产生大�wscript.exe

taskkill /IM wscript.exe /F
taskkill /IM cscript.exe /F
taskkill /IM consent.exe /F
taskkill /IM ChsIME.exe /F

所有建议�务器上�行vbs�,如果出现大�wscript.exe进程,�以加上下�的命令

dim WSHshell 
set WSHshell = wscript.createobject("wscript.shell") 
WSHshell.run "taskkill /im wscript.exe /f ",0 ,true

到此这篇关于使用vbs脚本�监控windows�务器上的应用程��存在就�动)的文章就介�到这�更多相关vbs守�进程内容请�索脚本之家以�的文章或继续�览下�的相关文章希望大家以�多多支�脚本之家�/p>