santhosh
santhosh

Reputation:

How can I start and stop services on a remote machine?

I have a requirement in the project such that we have to stop a specific service say "x" in a remote machine (which is on the same LAN), change the registry key remotely and start the service again.

I tried the command sc \server stop service, but I got the error:

[SC] GetServiceKeyName FAILED 1060:

The specified service does not exist as an installed service.

I am using Windows 2003 SP1. Are there any built in commands or APIs that are available on Windows?

I need the commmand to run on the command prompt.

Upvotes: 3

Views: 19421

Answers (4)

Mark R.
Mark R.

Reputation: 159

Also keep in mind that the "service name" argument expected by the "sc" command line tool doesn't always equate to the name you see within the services control panel applet (which is the service "display name").

For example, the service that as appears "Adobe Acrobat Update Service" in my services control panel applet has an actual name of "AdobeARMservice". You must use the latter, but not the former, when managing the service through the "sc" utility.

Example:

sc Stop "AdobeARMservice" (works)
sc Stop "Adobe Acrobat Update Service" (doesn't work)

To get the "real" name of a service, double-click its entry in the service control panel applet and see the "service name" field on the General tab.

Of course in some cases, the display name and the service name are the same.

Upvotes: 7

David Segonds
David Segonds

Reputation: 84742

You may want to look into PSTools from SysInternals. Those tools are freely available and can help you manage processes on a remote Windows machine.

The tools included in the PsTools suite, which are downloadable as a package, are:

PsExec - execute processes remotely
PsFile - shows files opened remotely
PsGetSid - display the SID of a computer or a user
PsInfo - list information about a system
PsKill - kill processes by name or process ID
PsList - list detailed information about processes
PsLoggedOn - see who's logged on locally and via resource sharing 
PsLogList - dump event log records
PsPasswd - changes account passwords
PsService - view and control services
PsShutdown - shuts down and optionally reboots a computer
PsSuspend - suspends processes
PsUptime - shows you how long a system has been running since its last reboot

Upvotes: 4

gahooa
gahooa

Reputation: 137312

From this URL:

To stop a service remotely you can use the command sc.

Example:
> sc \\computer stop "Service Name"
> sc \\computer start "Service Name"

Perhaps you are missing a "\" character?

Upvotes: 2

sharptooth
sharptooth

Reputation: 170499

Use OpenCSManager, then OpenService, then StartService.

Upvotes: 0

Related Questions