Re: Restarting a service - help a noob day!



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.
>
>
>


.



Relevant Pages

  • Re: Restarting a service - help a noob day!
    ... Pete wrote: ... > Trying to write a vbs to add a printer then stop and restart the spool ... > service on remote computers. ... Is there a better way Do loop until maybe. ...
    (microsoft.public.scripting.vbscript)
  • Re: Intermittant sudden re-booting...
    ... Pete L wrote: ... uncheck Automatically Restart. ... message instead of a reboot. ... device driver problem or a hardware problem but since the auto restart ...
    (microsoft.public.windowsxp.general)
  • Summary: System crashing in loop
    ... OBP firmware version. ... but will crash and end up in a state ... The only way out of this loop, is to power off the system ... and restart. ...
    (SunManagers)
  • Re: Do Until... Restart
    ... An IF statement in the loop will do it, with no need to restart ... where I've said Reset B1:B500. ... The macro must run until there are exactly 100 instances of 15 in B1:B500 ...
    (microsoft.public.excel.programming)
  • Re: *p++ = *q++ undefined? why?
    ... pete wrote: ... and the loop never ends. ... The loop attempts to overwrite memory beyond the bounds ... of the array, that's undefined behavior. ...
    (comp.lang.c)