Guest Brock Hensley Posted December 27, 2007 Posted December 27, 2007 Hello, I am looking to program a script to go through a list of servers and check the status of the 'DNS Server' service. We are currently running into a repetitive problem with our Virtual Private Servers in which upon windows updates auto reboots, the DNS Server service gets stuck in the 'Starting' stage and requires another reboot to get it to be operational. I'm experienced in PHP/Perl/Bash Shell scripting, but these are Windows Servers and I'm looking for some insight as to how to check the status of certain services semi-automatically. Any tips appreciated. -B
Guest Brock Hensley Posted December 27, 2007 Posted December 27, 2007 Re: Script to check Service Status? Well I found the following, havn't tried it out but we'll see :) http://www.adminscripteditor.com/scriptlibrary/view.asp?id=278 Dim $statuscode Dim $service Dim $ret $statuscode = Split("not installed,stopped,starting,stopping,running,resuming,pausing,paused,error",",") If $service="" ?"Give name of service to check :" Gets $service EndIf ?"Service " + $service + " is " + $statuscode[udf_checkservicestate($service)] ? ?"Press any key to continue ... " Get $ret ;****************************************************************************** ;* ;* SART OF $udf_CheckServiceState ;* ;* udf: Check Status of Service Service ;****************************************************************************** Function udf_CheckServiceState($svcname) ;****************************************************************************** ;* Declaration of local variables ;****************************************************************************** Dim $localstring Dim $ADSICompObj ;****************************************************************************** ;* Initialization of variables ;****************************************************************************** $localstring = "WinNT://" + @wksta + "/" + $svcname + ",service" ;****************************************************************************** ;* Check if Service $servicename is running ;****************************************************************************** $ADSICompObj = GetObject($localstring) If @error=0 $udf_CheckServiceState=$ADSICompObj.status EndIf EndFunction ;****************************************************************************** ;* ;* END OF udf_CheckServiceState ;* ;****************************************************************************** "Brock Hensley" <brock.hensley@serverintellect.com> wrote in message news:%23wUoKnLSIHA.4584@TK2MSFTNGP03.phx.gbl... > Hello, > > I am looking to program a script to go through a list of servers and check > the status of the 'DNS Server' service. > > We are currently running into a repetitive problem with our Virtual > Private Servers in which upon windows updates auto reboots, the DNS Server > service gets stuck in the 'Starting' stage and requires another reboot to > get it to be operational. > > I'm experienced in PHP/Perl/Bash Shell scripting, but these are Windows > Servers and I'm looking for some insight as to how to check the status of > certain services semi-automatically. > > Any tips appreciated. > > -B >
Guest Masterplan Posted December 28, 2007 Posted December 28, 2007 Re: Script to check Service Status? Hi Brock, I use a scheduled task with a script like this: SC \\servername query DNS | find /i "running". "Brock Hensley" wrote: > Well I found the following, havn't tried it out but we'll see :) > > http://www.adminscripteditor.com/scriptlibrary/view.asp?id=278 > > > > Dim $statuscode > Dim $service > Dim $ret > > $statuscode = Split("not > installed,stopped,starting,stopping,running,resuming,pausing,paused,error",",") > > If $service="" > ?"Give name of service to check :" > Gets $service > EndIf > > ?"Service " + $service + " is " + > $statuscode[udf_checkservicestate($service)] > ? > ?"Press any key to continue ... " > > Get $ret > > ;****************************************************************************** > ;* > ;* SART OF $udf_CheckServiceState > ;* > ;* udf: Check Status of Service Service > ;****************************************************************************** > > Function udf_CheckServiceState($svcname) > > ;****************************************************************************** > ;* Declaration of local variables > ;****************************************************************************** > > Dim $localstring > Dim $ADSICompObj > > ;****************************************************************************** > ;* Initialization of variables > ;****************************************************************************** > > $localstring = "WinNT://" + @wksta + "/" + $svcname + ",service" > > ;****************************************************************************** > ;* Check if Service $servicename is running > ;****************************************************************************** > > $ADSICompObj = GetObject($localstring) > If @error=0 > $udf_CheckServiceState=$ADSICompObj.status > EndIf > > EndFunction > > ;****************************************************************************** > ;* > ;* END OF udf_CheckServiceState > ;* > ;****************************************************************************** > > > > "Brock Hensley" <brock.hensley@serverintellect.com> wrote in message > news:%23wUoKnLSIHA.4584@TK2MSFTNGP03.phx.gbl... > > Hello, > > > > I am looking to program a script to go through a list of servers and check > > the status of the 'DNS Server' service. > > > > We are currently running into a repetitive problem with our Virtual > > Private Servers in which upon windows updates auto reboots, the DNS Server > > service gets stuck in the 'Starting' stage and requires another reboot to > > get it to be operational. > > > > I'm experienced in PHP/Perl/Bash Shell scripting, but these are Windows > > Servers and I'm looking for some insight as to how to check the status of > > certain services semi-automatically. > > > > Any tips appreciated. > > > > -B > > > > >
Recommended Posts