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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shutdown Order / services

Status
Not open for further replies.

mercwrought

Programmer
Dec 2, 2004
176
US
Hi all, it is question time. I need to change the order in which services shutdown in several different OS mainly server 2000. does anyone know any thing about this. I have searched and found how to get the services to start in a specific order which by the way a nightmare in reg editing but I have not found out how to stop them in a specific order. What I want to do is move my VNC server to as close to the last of the list as possible so that if one of the other services hang during restart I am still connected and can fix it.
 
The simplest way to do this is to write a script to shut the services down for you. In a batch file put:

net stop <service 1>
IF NOT ERRORLEVEL 0 goto getout
Net stop <service 2>
IF NOT ERRORLEVEL 0 goto getout
.
.
net stop <service n>
IF NOT ERRORLEVEL 0 goto getout
shutdown /R /T:10 "All services shutdown - rebooting" /C
:getout


This gives you total control of the services. You should only worry about the application type ones - the base Windows ones you can leave Windows to worry about.
 
Wait, wait a second.

The above completely ignores dependent Services, would be incredibly workstation specific, tedious, and unlikely to in the end resolve the issue.

Shutdown.exe is a reskit tool under Win2k. And note that the -F force option is missing.

This is not a satisfactory solution. Natively Win2k sends a notification message to all open processes, including services, and nicely asks them to close.

The real issue here is that in a solid, good working machine, there should not be a Service hang. Resolve the underlying Service issue.

What you want to do is not in any way scheduled: WM_CLOSE as a Win32 API request is made, and the running processes and servers respond on their own plan. This is not controllable.

Resolve the hung service. Workarouns are decidedly ugly for such an issue.

Resolve the problem, do not try (it cannot be done as the responses are asynchronous to a WM_CLOSE) scheduling or anything else as a workaround.

Please see as well:

. the Budja Shutdown forum: . Really force things to close: The shutdown utility on this site (freeware):
 
Yup - I agree it's tedious. It is a solution but not the best one. I've only done it this way on a couple of servers due to some services taking forever to shut down.

Also, I agree that the underlying problem should be solved and not left to a kludge way of shutting down.

And the dependent services should be taken care of by the script.

As for the /f - I must be getting old 'cos it used to to be /C :)
 
I total agree with you, we have resolved all hung services issues. I have not seen a hung service on that machine for about 6 months. This is a “just in case” measure. In the past we have had that that issue and I do not want to drive in to work if it rears its ugly head again just to restart a machine. Thx for all of your answers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top