VB/Windows script to check the service status

Great for for getting all Windows related scripts.

VB/Windows script to check the service status

Postby Praveen » Mon May 11, 2009 5:15 pm

This script is used to check the service status in a system whether it is running or its in stopped state
change the service name as per your requrement. here i mentioned the telnet service. you can check this in services.msc

Code: Select all

'Windows script to check the service status
'script by praveen & Subash
strComputer = "."
set shell=createobject("wscript.shell")
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where DisplayName = 'Telnet'")

For each objService in colListOfServices
    If objService.state = "Running" Then
   Msgbox "Telnet service is Running"
   Else
   MsgBox "Telnet service is in Stopped state"
   End if
Next
User avatar
Praveen
Site Admin
 
Posts: 84
Joined: Sat Apr 25, 2009 2:21 pm

Return to Windows Scripting/WMI/VBScript

Who is online

Users browsing this forum: No registered users and 0 guests

cron