Solved

Stop Windows Service Before Shutdown Automatically

Posted on 2014-02-18
4
3,061 Views
Last Modified: 2014-02-24
We have a data intensive program that if you do not stop before shutting down, it will require a build of the cache before running again. Even worse is the program will not do any other operations before the data is rebuilt. On large systems this can take days.

The software developers claim their is no way to stop the service properly when a user calls the shutdown command since newer versions of Windows just kills everything.

I just have a hard time accepting the answer there is nothing we can do. "Just stop the service first."

I just Google'd this before I submitted this question and I found this link:
http://www.dba-oracle.com/windows_add_oracle_shutdown_script.htm

Would this work for both Windows 7/8 & 2008/2012?
0
Comment
Question by:bselltiz
  • 3
4 Comments
 
LVL 93

Expert Comment

by:John Hurst
ID: 39868308
You could invoke a batch file to shut down.

NET STOP SERVICE
(Pause if you wish0
SHUTDOWN /s

That should work.
0
 

Author Comment

by:bselltiz
ID: 39868352
Right, I thought about this as well, but the solution must not deter people from normal Windows operation. Unless someone was told specifically to use that batch file to shutdown they wouldn't. Then what happens when they forget, which is why I'm here now. So the problem would still persist.

As long as the above link works on 7/8 & 2008/2012 I think that might be solution, unless someone has a better way to do this.

Thank you for the reply.
0
 
LVL 93

Accepted Solution

by:
John Hurst earned 500 total points
ID: 39868378
You should be able to add a script to the Windows shutdown area. You need to run gpedit.msc to enable the script. Then put a batch file in the logoff script area:

C:\Windows\System32\GroupPolicy\User\Scripts\Logoff

That script will run at shutdown (and also at logoff) and can stop the service.

You can put a script to start the service at logon.
0
 
LVL 93

Expert Comment

by:John Hurst
ID: 39882697
@bselltiz - Thank you and I was happy to help.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.

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