Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Service restart logging

Status
Not open for further replies.

staro30

IS-IT--Management
Dec 2, 2003
12
GB
Hi,

I have a 3rd party service that when restarted does not put anything into the event log. I have set the service to restart automatically every morning using Task Scheduler. I think it is restarting but I would like to see a log to be 100% sure. How can I do this?

Thanks
Staro
 
I would create a script to start the service and write the eventlog.

E.g.
Code:
Const EVENT_SUCCESS = 0
Set WshShell = Wscript.CreateObject("Wscript.Shell")
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name='Messenger'")
For each objService in colServiceList
    errReturn = objService.StartService()
Next
wscript.sleep 200
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service " _
             & "where Name='Messenger'")

For Each objService In colServiceList
   StartMode = UCase(objService.StartMode)

'     WScript.Echo StartMode
  
   If (StartMode = "MANUAL") Or (StartMode = "Disabled") Then
       errReturnCode = objService.ChangeStartMode("AUTO")
   End If
Next
'Write the event log
WshShell.LogEvent EVENT_SUCCESS, _
    "3rd Party Service Started"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top