Problems with stopping/starting service 
Author Message
 Problems with stopping/starting service

I can get the script to stop the service but I can't get it to start the
service... any help???  working in NT4.

thanks

<=======VBS=======>

StopService sServer
WScript.Sleep 1200
StartService sServer
WScript.Sleep 1200

Function StopService(sSrvr)
Set cp = GetObject("WinNT://" & sSrvr)
Set so = cp.GetObject("Service", "Client Agent for ARCserve")
If (so.Status = ADS_SERVICE_RUNNING) Then ' The operation is running.
    so.Stop
End If
End Function

Function StartService(sSrvr)
Set cp = GetObject("WinNT://" & sSrvr)
Set so = cp.GetObject("Service", "Client Agent for ARCserve")
If (so.Status <> ADS_SERVICE_RUNNING) Then ' The operation is not running.
    so.Start
End If
End Function

<=======VBS=======>



Sat, 02 Jul 2005 05:58:46 GMT  
 Problems with stopping/starting service
Maybe give the service longer than 1.2 seconds to stop prior to sending a
start?


Quote:
> I can get the script to stop the service but I can't get it to start the
> service... any help???  working in NT4.

> thanks

> <=======VBS=======>

> StopService sServer
> WScript.Sleep 1200
> StartService sServer
> WScript.Sleep 1200

> Function StopService(sSrvr)
> Set cp = GetObject("WinNT://" & sSrvr)
> Set so = cp.GetObject("Service", "Client Agent for ARCserve")
> If (so.Status = ADS_SERVICE_RUNNING) Then ' The operation is running.
>     so.Stop
> End If
> End Function

> Function StartService(sSrvr)
> Set cp = GetObject("WinNT://" & sSrvr)
> Set so = cp.GetObject("Service", "Client Agent for ARCserve")
> If (so.Status <> ADS_SERVICE_RUNNING) Then ' The operation is not running.
>     so.Start
> End If
> End Function

> <=======VBS=======>



Sat, 02 Jul 2005 06:22:53 GMT  
 Problems with stopping/starting service
It's not that... when I manually stop the service and then start it with the
script it fail to start the service.  However, the script will stop the
service.  I am having a hard time trying to wrap my brain around this one.


Quote:
> Maybe give the service longer than 1.2 seconds to stop prior to sending a
> start?



> > I can get the script to stop the service but I can't get it to start the
> > service... any help???  working in NT4.

> > thanks

> > <=======VBS=======>

> > StopService sServer
> > WScript.Sleep 1200
> > StartService sServer
> > WScript.Sleep 1200

> > Function StopService(sSrvr)
> > Set cp = GetObject("WinNT://" & sSrvr)
> > Set so = cp.GetObject("Service", "Client Agent for ARCserve")
> > If (so.Status = ADS_SERVICE_RUNNING) Then ' The operation is running.
> >     so.Stop
> > End If
> > End Function

> > Function StartService(sSrvr)
> > Set cp = GetObject("WinNT://" & sSrvr)
> > Set so = cp.GetObject("Service", "Client Agent for ARCserve")
> > If (so.Status <> ADS_SERVICE_RUNNING) Then ' The operation is not
running.
> >     so.Start
> > End If
> > End Function

> > <=======VBS=======>



Sat, 02 Jul 2005 06:33:47 GMT  
 Problems with stopping/starting service

Quote:

> I can get the script to stop the service but I can't get it to start the
> service... any help???  working in NT4.

> (snip)

> Function StartService(sSrvr)
>   Set cp = GetObject("WinNT://" & sSrvr)
>   Set so = cp.GetObject("Service", "Client Agent for ARCserve")
>   If (so.Status <> ADS_SERVICE_RUNNING) Then ' The operation is not running.
>     so.Start
>   End If
> End Function

Hi

Try to change the "Client Agent for ARCserve" (that I guess it is the Display
name) to the short-version of the name (the real service name).

Running your script on the Fax service on my computer (Win2k) gave this result:

With the long Display name, I got the error "Active Directory: Unspecified
error" on this line:

Set so = cp.GetObject("Service", "Fax Service")

This worked much better, the service started:

Set so = cp.GetObject("Service", "Fax")

I can't see that you define ADS_SERVICE_RUNNING in your script either, you
should have this line placed globally, or in each function:

Const ADS_SERVICE_RUNNING = 4

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Sat, 02 Jul 2005 07:16:05 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Starting, stopping and pauseing a service.

2. How to start/stop services with vbscript?

3. START/STOP/ displayed Services running on PC thu an ASP page

4. How to start/stop a NT service

5. start and stop services

6. login script to start/stop service

7. stop/start a service in VBS

8. Stop and Starting Services on NT

9. Starting and Stopping NT Services with ADSI,wsh, and VBScript

10. Start/Stop a NT Service using wsh/adsi

11. Starting and stopping Services from ASP or VBS

12. Service Stop/Start

 

 
Powered by phpBB® Forum Software