Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am looking for a method of starting/stopping a service on a remote Windows 2003 Server. Locally I know that the net command works, but is there a way to do this over the network?

EDIT: Looking to be able to do this in a script, external GUI tools won't work unless they have a command line tool.

share|improve this question

8 Answers 8

up vote 7 down vote accepted

Use the "sc.exe" command from the Windows Server Resource Kit.

An example, to configure a the IIS service to Autostart and then to start it:

sc \\server1 config w3svc start= auto
sc \\server1 start w3svc
share|improve this answer
    
FWIW, sc.exe is built-in from Server 2003 onwards. –  ThatGraemeGuy Jun 1 '09 at 21:47
    
Thanks... I thought that might be true but was too lazy to check.. ;-) –  Ryan Fisher Jun 2 '09 at 21:39
    
FWIW2: the sc command that comes with XP is not compatible with the w2k3 version. Use only the w2k3 version for w2k3 servers. –  katriel Jul 30 '09 at 22:46
    
Also, using the sc "config" command to change the service startup is "start=", a space and then "auto". No, I'm not kidding. Yes, it's weird and screws me up all the time. –  Ryan Fisher Nov 10 '09 at 19:15

There is a free sysinternals tools called PsService that allows you to view status, start, stop services locally and on other machines.

share|improve this answer

Use the sc command:

sc [server] [command] [service name]
share|improve this answer

You could use the sc command.

Basically:

sc \\server stop wuauserv

sc \\server start wuauserv

For more info just type sc in a command prompt.

share|improve this answer

Start your Services administration tool on your local machine, right click on the "Services (Local)" entry and connect to the remote computer

This will give you the full services MMC for the remote machine

share|improve this answer
    
Nevermind, I see that you're asking about non-GUI tools –  Kevin Kuphal Jun 1 '09 at 21:41

If you're UNIXy at heart and working with Windows servers, do what I do. Install cygwin, configure opensshd and ssh in to use net start / net stop.

share|improve this answer

Obviously `sc' has been touched upon quite frequently, here's an alternative for you:

There's a GREAT group of utilities out there written by Mark Russinovitch called "PSTools" which has that capability. Specifically `psexec' can do that for you.

share|improve this answer

Also, i found this Powershell script on the net:

####################################################################################
#PoSH script to check if a server is up and if it is check for a service.
#If the service isn't running, start it and send an email
# JK - 7/2009
#Updated: 07/22/09 by Steven Murawski (http://blog.usepowershell.com)
#Changed the ping result comparison to use the .NET Enum
####################################################################################

$erroractionpreference = "SilentlyContinue"

$i = "testserver"   #Server Name
$service = "spooler"    #Service to monitor

 $ping = new-object System.Net.NetworkInformation.Ping
    $rslt = $ping.send($i)
        if ($rslt.status –eq [System.Net.NetworkInformation.IPStatus]::Success)
{
        $b = get-wmiobject win32_service -computername $i -Filter "Name = '$service'"

    If ($b.state -eq "stopped")
    {
    $b.startservice()

    $emailFrom = "services@yourdomain.com"
    $emailTo = "you@yourdomain.com"
    $subject = "$service Service has restarted on $i"
    $body = "The $service service on $i has crashed and been restarted"
    $smtpServer = "xx.yourdomain.com"
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $smtp.Send($emailFrom, $emailTo, $subject, $body)
    }

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.