Previous Posts


Get rid of those unhelpful printer balloon notific...

Hide user accounts from the Windows XP Welcome scr...

New version of Remote Reboot released

Deleting prefetch folder *does* improve boot time....

Why windows takes so long to start up.

Disable CD Rom Drives

Disable Floppy Drives - Remotely

Disable Floppy Drives

Why Windows takes so long to shut down.

Disable USB drives - remotely



Archives

May 2005

January 2006

April 2006

May 2006

June 2006

July 2006

September 2006

October 2006

November 2006

December 2006

January 2007

February 2007

March 2007

April 2007

May 2007

June 2007

July 2007

August 2007

September 2007

October 2007

November 2007

December 2007

January 2008

February 2008

March 2008

April 2008

May 2008



Subscribe to our Feed:






Starting and stopping services across an entire domain

Stopping and starting services within windows is quite easy. From the command line you can simply type:

net stop to stop a service

or

net start to start a service

Or even easier, open the service manager by clicking on start, run and then type 'services.msc' and click OK



A complete list of services is displayed:



Now you can right click on the service you would like to modify, and start or stop it using the respective menus.

The tricky part is when you need to stop the same service on 400 machines across your LAN. That could be a real pain. What if, for example, a critical flaw was found in VNC and you wanted to quickly stop it on every machine within your network?

The first question we need to ask: How can we stop or start a service remotely?

One way is to use the GUI. The service manager I showed you before can connect to a remote computer. Using this method it takes three clicks and about 45 seconds. 45 Seconds x 400 machines = about 5 hours of lots of clicking.

We definitely want to use the command line for this one.

Microsoft has a utility in the resource kit for Windows XP professional named (sc.exe)

It follows this syntax:

sc.exe computername action service_name

It lets you start and stop services of a remote computer from the command line. Now we are on the right track. Still...I don't like the way this program operates. The major feature it is missing is authentication. I want to provide a username and password all in the same command line tool.

I took the liberty to create such a tool. (Free) It can be downloaded from here

It follows this syntax:

RemoteService.exe HOST ACTION SERVICENAME [USERNAME] [PASSWORD]

Possible actions are: STOP, or START

Username and password are optional.

Here is what it would look like if we used it to start and stop WinVNC on a computer named Computer1



Now. How do we automate this to stop or start a service on *every* computer within a domain? Simple: We create a VB script that will do it for us.

You can download it from here (Right click, and Save As...)

RemoteService.vbs

Here is how it works:

It gets a list of all the computers within the domain you specify. Then it executes our RemoteService.exe with the appropriate command line parameters. RemoteService.exe then returns an exit code, which we use to display the result.

Here is the syntax for the script

RemoteService.vbs Domain Action ServiceName [UserName] [Password]

Action can be either STOP, or START

Again, username and password are optional

I suggest using the cscript.exe VB Script interpreter to invoke it, otherwise you will get a message box for each machine that it processes.

Lets see an example use of the script. Lets say I want to stop WinVNC on all machines within the IntelliAdmin domain:

cscript.exe RemoteService.vbs IntelliAdmin Stop WinVNC

(Make sure RemoteService.vbs and RemoteService.exe are in the same folder)

Another question that pops up is: What is the appropriate service name for use on the command line?

This is a good question. If we go back to our service list that we viewed before (By Launching services.msc) We can double click on any of the services. Now a property window will be shown.



The "Service Name" is what you need to use when invoking the script. It sometimes can be confusing since the name of the service displayed in the GUI can be totally different than the name you can use within the command line.

That's all there is to it. Now with only one line in the command window you can stop or start a service across your entire domain.


Posted By: Steve Wiseman on Friday, September 22, 2006

Check out our utilities for windows

 



Copyright © IntelliAdmin, LLC, 2008. All Rights Reserved