Stopping and Starting NT Services 
Author Message
 Stopping and Starting NT Services

I'm using WSH and VBScripts.
Is there a way of
testing if a specific NT Service is running and,
depending on the outcome of the test,
stop or start the service using WSH scripting?

Kjell



Sun, 22 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services

  Service.status

  1 = stopped or disabled
  4 = started
  7 = paused

  Clarence
  Check it out..

  Http://cwashington.netreach.net

  On this site you will find resources for all of your scripting needs. Everything you need to get up and running. Over 100 Sample Scripts, ActiveX controls, reference materials, and technical support via an online discussion lounge.

  [ Win32Scripting... automate!! ]

I'm using WSH and VBScripts.
Is there a way of
testing if a specific NT Service is running and,
depending on the outcome of the test,
stop or start the service using WSH scripting?

Kjell



Sun, 22 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services

can you be a little more specific?  a search at your site for server.status or for server status gave no hits...

--
Mike Harris


        Service.status

        1 = stopped or disabled
        4 = started
        7 = paused

        Clarence
        Check it out..

        Http://cwashington.netreach.net

        On this site you will find resources for all of your scripting needs. Everything you need to get up and running. Over 100 Sample Scripts, ActiveX controls, reference materials, and technical support via an online discussion lounge.

        [ Win32Scripting... automate!! ]


    I'm using WSH and VBScripts.
    Is there a way of
    testing if a specific NT Service is running and,
    depending on the outcome of the test,
    stop or start the service using WSH scripting?

    Kjell



Sun, 22 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services

I thought I was....

Set Service = ("WinNT://Your_computer/Your_service")
If Service.Status = 1 then
    msgbox "service is stopped"
End If

You need ADSI first

Clarence

can you be a little more specific?  a search at your site for server.status or for server status gave no hits...

--
Mike Harris


    Service.status

    1 = stopped or disabled
    4 = started
    7 = paused

    Clarence
    Check it out..

    Http://cwashington.netreach.net

    On this site you will find resources for all of your scripting needs. Everything you need to get up and running. Over 100 Sample Scripts, ActiveX controls, reference materials, and technical support via an online discussion lounge.

    [ Win32Scripting... automate!! ]


  I'm using WSH and VBScripts.
  Is there a way of
  testing if a specific NT Service is running and,
  depending on the outcome of the test,
  stop or start the service using WSH scripting?

  Kjell



Sun, 22 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services

I was just curious...  I'm working on a standalone Win98 box at home but NT4 (with ADSI v.something) at work.

--
Mike Harris


    I thought I was....

    Set Service = ("WinNT://Your_computer/Your_service")
    If Service.Status = 1 then
        msgbox "service is stopped"
    End If

    You need ADSI first

    Clarence


    can you be a little more specific?  a search at your site for server.status or for server status gave no hits...

    --
    Mike Harris


            Service.status

            1 = stopped or disabled
            4 = started
            7 = paused

            Clarence
            Check it out..

            Http://cwashington.netreach.net

            On this site you will find resources for all of your scripting needs. Everything you need to get up and running. Over 100 Sample Scripts, ActiveX controls, reference materials, and technical support via an online discussion lounge.

            [ Win32Scripting... automate!! ]


        I'm using WSH and VBScripts.
        Is there a way of
        testing if a specific NT Service is running and,
        depending on the outcome of the test,
        stop or start the service using WSH scripting?

        Kjell



Sun, 22 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services

Got this to work on my NT box, but it's sloooooooow (15-25 seconds just to get the status)...

Is this typical for ADSI?

Box is P166 w/64MB memory.

--
Mike Harris


    I thought I was....

    Set Service = ("WinNT://Your_computer/Your_service")
    If Service.Status = 1 then
        msgbox "service is stopped"
    End If

    You need ADSI first

    Clarence


    can you be a little more specific?  a search at your site for server.status or for server status gave no hits...

    --
    Mike Harris


            Service.status

            1 = stopped or disabled
            4 = started
            7 = paused

            Clarence
            Check it out..

            Http://cwashington.netreach.net

            On this site you will find resources for all of your scripting needs. Everything you need to get up and running. Over 100 Sample Scripts, ActiveX controls, reference materials, and technical support via an online discussion lounge.

            [ Win32Scripting... automate!! ]


        I'm using WSH and VBScripts.
        Is there a way of
        testing if a specific NT Service is running and,
        depending on the outcome of the test,
        stop or start the service using WSH scripting?

        Kjell



Wed, 25 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services
The following script should do the job for you. Ofcourse you would have to
edit it to customize.

*************************************************Start of
Script************************

DIM Serv

nextline = CHR("13")
spacer = CHR("9")

Set Dom = GetObject("WinNT://YourDomain") ' Enter your domain name
Dom.Filter = Array("Computer")

call servicelist()

wscript.quit

Sub Servicelist()

for each comp in Dom
 comp.Filter = Array("Service")
  for each serv in comp
   List = List & spacer & Serv.Name & nextline ' Display Service Name
   msgbox List
   If serv.Name = "Browser"   and serv.Status = 1 then
      serv.Start
   End If
  next
next
end sub
***************************************End of
Script*****************************

Quote:

>I'm using WSH and VBScripts.
>Is there a way of
>testing if a specific NT Service is running and,
>depending on the outcome of the test,
>stop or start the service using WSH scripting?

>Kjell



Thu, 26 Jul 2001 03:00:00 GMT  
 Stopping and Starting NT Services
You could use the sledge hammer approach. Just try to start the service. If
you get an error, it's already running.

Dave Plummer

Quote:

>I'm using WSH and VBScripts.
>Is there a way of
>testing if a specific NT Service is running and,
>depending on the outcome of the test,
>stop or start the service using WSH scripting?

>Kjell



Fri, 27 Jul 2001 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Stopping and Starting NT Services

2. How to start/stop a NT service

3. Stop and Starting Services on NT

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

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

6. Starting and stopping NT services

7. How to start/stop a NT service...

8. Script To Stop/Start NT Service

9. Starting and Stopping NT Services from WSH/VBS

10. Stop/Start NT Services

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

12. Starting/Stopping NT Services

 

 
Powered by phpBB® Forum Software