Solved

Command Line to Stop / Start Services on Server

Posted on 2009-05-05
9
864 Views
Last Modified: 2013-11-09
How would I stop a service on a different server from the command line. I am on SERVER1 and want to stop a service on SERVER2 and then I want to start the service again.
0
Comment
Question by:jamesh1031
9 Comments
 
LVL 18

Expert Comment

by:flyingsky
ID: 24307769
0
 
LVL 4

Accepted Solution

by:
BillCarlin earned 500 total points
ID: 24307770
Easiest way is to use PSTools.  You can download from here:
https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx?ppud=4

-Cheers
0
 
LVL 24

Expert Comment

by:Rajith Enchiparambil
ID: 24307971
Use netsvc (Command-line Service Controller - You can use NetSvc to remotely start, stop, and query the status of services from the command line) from 2000 resource kit tools
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:jamesh1031
ID: 24326863
If I am on 10.102.100.150 and want to stop a service on 10.102.100.151 named XZY what do i type in the command prompt on 150 to stop and start the service?
0
 
LVL 4

Assisted Solution

by:BillCarlin
BillCarlin earned 500 total points
ID: 24520136
If the author had looked at PSTOOLS using the link provided as instructed, he would have been given the direction and means to accomplish his task.  As taken from PsService:

PsService v2.22
By Mark Russinovich
Published: January 11, 2008
Introduction
PsService is a service viewer and controller for Windows. Like the SC utility that's included in the Windows NT and Windows 2000 Resource Kits, PsService displays the status, configuration, and dependencies of a service, and allows you to start, stop, pause, resume and restart them. Unlike the SC utility, PsService enables you to logon to a remote system using a different account, for cases when the account from which you run it doesn't have required permissions on the remote system. PsService includes a unique service-search capability, which identifies active instances of a service on your network. You would use the search feature if you wanted to locate systems running DHCP servers, for instance.

Finally, PsService works on both NT 4, Windows 2000 and Windows Vista, whereas the Windows 2000 Resource Kit version of SC requires Windows 2000, and PsService doesn't require you to manually enter a "resume index" in order to obtain a complete listing of service information.>

 

Installation
Just copy PsService onto your executable path, and type "psservice".


 

Using PsService
The default behavior of PsService is to display the configured services (both running and stopped) on the local system. Entering a command on the command-line invokes a particular feature, and some commands accept options. Typing a command followed by "- " displays information on the syntax for the command.

Usage: psservice [\\computer [-u username] [-p password]] <command> <options>

query Displays the status of a service.
config Displays the configuration of a service.
setconfig Sets the start type (disabled, auto, demand) of a service.
start Starts a service.
stop Stops a service.
restart Stops and then restarts a service.
pause Pauses a service
cont Resumes a paused service.
depend Lists the services dependent on the one specified.
security Dumps the service's security descriptor.
find Searches the network for the specified service.
\\computer Targets the NT/Win2K system specified. Include the -u switch with a username and password to login to the remote system if your security credentials do not permit you to obtain performance counter information from the remote system. If you specify the -u option, but not a password with the -p option, PsService will prompt you to enter the password and will not echo it to the screen.
0
 

Author Comment

by:jamesh1031
ID: 24526326
I still don't have enough of an answer to solve my problem.

If I am on 10.102.100.150 and want to stop a service on 10.102.100.151 named XZY what do i type in the command prompt on 150 to stop and start the service? Assume user name is user1 and password is password1. I have installed psservice on 150. Do I need it on 151 also? I don't see where the name of the service I want to stop should go. I don't know what the  brackets [ ] and <> mean. Looks like I leave the brackets and just place the command in place of the <command> (don't use <>)
 
psservice [\\computer [-u username] [-p password]] <command> <options>


0
 
LVL 4

Assisted Solution

by:BillCarlin
BillCarlin earned 500 total points
ID: 24527770
Please or launch psservice -? to learn how to use psservice
Examples:
Copied to Local Machine:
c:\temp\psservice -u AdminNameHere -p ******* setconfig seclogon auto
c:\temp\psservice -u AdminNameHere -p ******* start seclogon

From Master machine to remote:
psservice \\XZY restart spooler

You can run this from 1 master server and remote administer or if network firewalls don't permit, you can use the local option.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Marketers need statistics and metrics like everybody else needs oxygen. In this article we explain how to enable marketing campaign statistics for Microsoft Exchange mail.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question