欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用vbs腳本來監(jiān)控windows服務器上的應用程序(不存在就啟動)

 更新時間:2024年04月14日 22:07:54   作者:SYSCTO  
這個vbs代碼主要實現(xiàn)的功能就是運行該程序,就會在進程中出現(xiàn)一個wscript.exe?它會每隔10s掃面一次進程中是否存在notepad.exe這個程序,不存在就啟動。這個啟動程序可能跟進程名不一樣,好比tomcat應用,啟動的是startup.bat,后臺進程名為java.exe

這個vbs代碼主要實現(xiàn)的功能就是運行該程序,就會在進程中出現(xiàn)一個wscript.exe 它會每隔10s掃面一次進程中是否存在notepad.exe這個程序,不存在就啟動。這個啟動程序可能跟進程名不一樣,好比tomcat應用,啟動的是startup.bat,后臺進程名為java.exe,這樣就需要調(diào)整代碼proname="java.exe"

關于如果關掉監(jiān)控 可以在運行下執(zhí)行taskkill /f /im wscript.exe 或者在任務管理器 進程中找到wscript.exe 結(jié)束進程就可以了

調(diào)整WshShell.Run("startup.bat")

核心代碼

dim wmi,proc,procs,proname,flag,WshShell
Do
proname="notepadjb51.exe" '需要監(jiān)測的服務進程的名稱,自行替換這里的記事本進程名
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寫個小腳本 實時監(jiān)測指定程序是否運行 對運行的軟件進行操作 最后關閉運行軟件

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

批處理檢測進程是否存在;這個我用來檢測文化進程是否存在,因為是綠色版的,很容易被關閉,所以需要檢測。

tasklist /nh|find /i "ClientOfWatcher.exe"
if ERRORLEVEL 1 (start C:\watcher\ClientOfWatcher.exe) else (exit)

VBS定時檢測進程是否存在,如果不存在就啟動進程。

option Explicit    
dim wmi,proc,procs,proname,flag,WshShell    
Do  
    proname="ClientOfWatcher.exe" '需要監(jiān)測的服務進程的名稱,自行替換這里的記事本進程名    
set wmi=getobject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")    
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:\Watcher\ClientOfWatcher.exe")    
end if    
  wscript.sleep 50000 '檢測間隔時間,這里是50秒    
loop

關于vbs系統(tǒng)運行后,系統(tǒng)進程中產(chǎn)生大量wscript.exe

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

所有建議服務器上運行vbs后,如果出現(xiàn)大量wscript.exe進程,可以加上下面的命令

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

到此這篇關于使用vbs腳本來監(jiān)控windows服務器上的應用程序(不存在就啟動)的文章就介紹到這了,更多相關vbs守衛(wèi)進程內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論