Solved

Stop Windows Service Before Shutdown Automatically

Posted on 2014-02-18
4
2,901 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 92

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 92

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 92

Expert Comment

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

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

So many times I have seen the words written in a question "if only I could show you" or " I know how hard it is for you since you can't see it" in any zone. That has inspired me to write about this tool in windows 7 called "Problem Steps Recorder…
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
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 give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now