Re: Restarting a service - help a noob day!
- From: "Pete" <xla760@xxxxxxxxxxxxxxx>
- Date: Thu, 9 Jun 2005 07:10:19 +0000 (UTC)
Thanks Michael
bulked it out a bit, works a treat.
"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:etBbAeJbFHA.2876@xxxxxxxxxxxxxxxxxxxxxxx
> Pete wrote:
>> Trying to write a vbs to add a printer then stop and restart the spool
>> service on remote computers (2000 and XP). Only problem is I can't
>> find a restart so I stop the service, then wait a bit, then start the
>> service. Is there a better way Do loop until maybe.
>>
>> Any advice appreciated.
>> Pete.
>> ''''''''''''''''''''''''''''''''''''''
>
>
>
> A simple solution...
>
> Set Service = GetObject("WinNT://" & strComputer & "/SPOOLER,Service")
> Service.Stop
>
> nLoopMax = 15
> nLoopCount = 0
>
> Do Until Service.Status = 1 ' ADS_SERVICE_STOPPED 0x00000001
> If nLoopCount > nLoopMax Then
> WScrupt.Echo "Spooler didn't stop..."
> Exit Loop
> End If
> WScript.Sleep 1000
> nLoopCount = nLoopCount + 1
> Loop
>
> If Service.Status = 1 Then
> Service.Start
> Else
> WScript.Echo "Service.Status =", Service.Status
> End If
>
> See:
>
> IADsServiceOperations.IADsServiceOperations Property Methods [ADSI]
> http://msdn.microsoft.com/library/en-us/adsi/adsi/iadsserviceoperations_property_methods.asp?frame=true
>
>
> --
> Michael Harris
> Microsoft MVP Scripting
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Please ask follow-up questions via the original newsgroup thread.
>
>
>
.
- References:
- Restarting a service - help a noob day!
- From: Pete
- Re: Restarting a service - help a noob day!
- From: Michael Harris \(MVP\)
- Restarting a service - help a noob day!
- Prev by Date: ## Re: automating internet explorer, also in the background
- Next by Date: Window Style
- Previous by thread: Re: Restarting a service - help a noob day!
- Next by thread: Finding name of a file in a directory
- Index(es):
Relevant Pages
|