Solved

Stop Windows Service Before Shutdown Automatically

Posted on 2014-02-18
4
3,182 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xcopy commands not running in batch file if user is logged out 5 44
Windows 7 Internet issue 14 54
Server 2012 R2 Radius server and Cisco AP 7 21
Upgrading Windows 7 2 22
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

808 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