Hej negerfrans
Det kan man da. Her er et script jeg har lavet der overvåger en service og sender en mail hvis servicen stopper:
strComputer = "servernavn"
Set objWMIService = GetObject("
winmgmts://" & strComputer & "/root/cimv2")
strWQL = "SELECT * " & _
"FROM __InstanceModificationEvent " & _
"WITHIN 2 " & _
"WHERE TargetInstance ISA 'Win32_Service' " & _
"AND TargetInstance.Name = 'Messenger'" & _
"AND TargetInstance.State = 'Stopped'"
Set objEventSource = objWMIService.ExecNotificationQuery(strWQL)
WScript.Echo "Monitoring the service..."
Set objEventObject = objEventSource.NextEvent()
WScript.Sleep(5000)
call sendemail
function sendemail
Const olMailItem = 0
strMsg = "email@domæne.com"
strReceipent = "email@domæne.com"
strSubject = "Service has stopped"
strBodyText = "The Service needs to be restarted"
Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set mItem = objOutlook.CreateItem(olMailItem)
mItem.To = strReceipent
mItem.Subject = strSubject
mItem.Body = strBodyText
mItem.Save
mItem.Send
Set mItem = Nothing
Set objNameSpace = Nothing
set objOutlook = Nothing
end function
Der skal være installeret en mailklient på serveren.
Håber du kan bruge det:):)