Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduler 2

Status
Not open for further replies.

dljohnson19

IS-IT--Management
Feb 7, 2005
37
US
I am trying to run the scheduler to use KILL to stop a service on Friday evenings. Does anyone know of a way to do this to kill a running service?
 
First off, you need to know what executable the service runs as. You could then use:

kill -f <executablename>.exe

However, doesn't Net Stop work.

You would be better off trying Net Stop, for instance:

Net Stop Server
Net Stop "Windows Audio"

etc.

If Net Stop does not work then the kill -f should work. There are occassions, however, whereby kill will hang, you can tell in your Task Manager/Processes the next morning.

Hope this helps.
 
Sorry, forgot to add, if using net stop and the service stopping has dependencies, then at the end you need /y

For instance:

net stop <servicename> /y

This will stop all services depending upon this service to stop as well (otherwise it will prompt for an answer).
 
Yeah, tried those with KILL and I don't get errors but it doesn't stop the service either. It has no dependancies.

When I try to net stop or net start the service it gives the message "the service name is invalid". But it is the correct named service. Tried it with and without quotes and with and without the .exe extension and it still acts like it cannot find it. Ideas?
 
The service is a custom service we made. This same service would always let us use the kill or net stop commands for killing the PID of the service and allowed us to kill it by name too. This was on NT 4 and I believe W2K server. I just seem to be having problems with it actually killing or stopping in 2003 server.

I ran it from the command line logged in as admin. Is that what you mean? (this is the way we had always done it before)
 
Yes, that is what I meant. What does it say in Event Viewer?

What happens if you try stopping the service using the GUI services Administrative Tool?

It is starting to sound as if your server thinks the service is called something else.

Try this:

Net Start >c:\services.txt

This will list the started services to a text file called services.txt on C:.

Find what the server thinks your service is called.

You can also search through the registry, try HKLM\System\CurrentControlSet\Services.

Click on Services and then do a find (I would recommend setting the reg editor to read only first, just in case) and search for you service name (for instance, searching "Print Spooler" will put you on the Display Name for "Spooler").

This should give you the actual name of the service, as in the above example, "Print Spooler" is Spooler.

You can do net stop or net start for both spooler or "Print Spooler".

This way you could try the "actual" name of your service.

Hope this helps.
 
You need to run this command from a batch file. Insert your command line in a .bat file, then run the batch from your scheduler. Also, you must define a user account for the scheduler to use. Once the user is defined, then the system will actually log that account in before the action is performed.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Thanks to PCS and to LiverPool. Both ideas worked fine. I am incorporating both ideas into my solution.
 
I don't know why, but I always had issues when I named a batch program with the ".bat" extension, and tried to schedule it.

Seems like it always works better when using the ".cmd" extension. This may have been an NT 4.0 server issue, but I stuck with the habit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top