Stopping and Starting services remotely

Discussion in 'Windows Server' started by Simon Guest, May 10, 2005.

  1. Simon Guest

    Simon Guest Guest

    Hi,

    I need to be able to start and stop a particular service on one of our W2k3
    servers from another workstation - ideally from a batch file so your average
    joe user can do it when instructed. After a bit of a search on the internet
    it would seem that there was a utility called Netsvc.exe in the NT4
    Resource Kit Supplement 1 that would allow you to do just this but I've
    scavanged the MS site and can no longer find this supplement. I did get the
    original NT4 RK but the required file is indeed not in there.

    Can anyone help with alternative methods or is there a newer utility that
    I'm unaware of?

    Thanks,

    Simon
     
    Simon Guest, May 10, 2005
    #1
    1. Advertisements

  2. Simon Guest

    Peter Lawton Guest

    Peter Lawton, May 10, 2005
    #2
    1. Advertisements

  3. Simon Guest

    richard Guest

    try "net start/stop"
     
    richard, May 10, 2005
    #3
  4. Simon Guest

    ik Guest

    http://www.google.nl/search?q=vbscr...ient=firefox-a&rls=org.mozilla:en-US:official

    gave me the URL:
    http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/services/


    Here is aan example VBscript:

    strComputer = "." should be replaced by strComputer = "Remote Computer
    Name"

    Starting a Service and Its Dependents

    Starts the NetDDE service and all its dependent services.

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name='NetDDE'")
    For each objService in colServiceList
    errReturn = objService.StartService()
    Next
    Wscript.Sleep 20000
    Set colServiceList = objWMIService.ExecQuery("Associators of " _
    & "{Win32_Service.Name='NetDDE'} Where " _
    & "AssocClass=Win32_DependentService " & "Role=Dependent" )
    For each objService in colServiceList
    objService.StartService()
    Next

    Stopping a Service and Its Dependents

    Stops the NetDDE service and all its dependent services.

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colServiceList = objWMIService.ExecQuery("Associators of " _
    & "{Win32_Service.Name='NetDDE'} Where " _
    & "AssocClass=Win32_DependentService " & "Role=Antecedent" )
    For each objService in colServiceList
    objService.StopService()
    Next
    Wscript.Sleep 20000
    Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name='NetDDE'")
    For each objService in colServiceList
    errReturn = objService.StopService()
     
    ik, May 10, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.