Wednesday, September 14, 2011

ShutdownUnless

ShutdownUnless

Current Version: 1.3

What is ShutdownUnless?

ShutdownUnless is a utility to shutdown a workstation or server, provided it doesn't have any open files you wouldn't want to be open when shutting down. Optionally ShutdownUnless will write to the Windows NT event log when a shutdown is aborted due to an open file.

purpose:

You wouldn't want to restart your server if some employee left a database dependent client app open on his/her workstation, because with the database stored on the restarting server, corruption may result; you'd rather abort that shutdown/restart!

If such a planned restart was aborted, you might even want this recorded in the event log, with a list of the open files preventing your shutdown in the event description!

In my case, I needed to script an automatic server restart on a weekend due to maintenance. Problem is, all clients of a particular program needed to be closed, and you can't guarantee that employees are shutdown their software before going home on Friday. (Sure, you could force the app to close on the workstation, but that may leave loose ends depending on the particular software that I'm not ready to deal with.)

My solution was ShutdownUnless. I schedule it with the Windows Task Scheduler just like any other method, but when it runs it tests for open files prior to shutdown, if they exist, it aborts and writes an entry to the Application Event Log. This is the extent of my app's functionality, and you can manually scan event logs if you like; however in my case (and maybe yours?) this event log entry can be scanned for with my existing remote management software and emailed to me, so I know that someone prevented a maintenance shutdown by leaving his client app open.

In the future, I hope to add additional functionality to make it more useful for more situations (running executable detection, better open file handle detection to include WHO on the network may have the file open, optional execution of scripts depending on which file may be open (like to shutdown a program on across a network, smtp for sending email alerts from within this program, etc.) but this may be the *distant* future because I'm lazy, busy, have a wife, and a child on the way.

revision history:

1.3 - Completely new Event Logging method which does away with the "description for Event ID ( 10177 ) in Source ( ShutdownUnless ) cannot be found." problem, and leaves the logged event description with only a nicely formatted representation of the facts. For this to work while using the event viewer, the executable MUST reside on the machine in the path in which it was last run, otherwise Event Description output will be like previous versions. This is a Windows Event Viewer quirk but shouldn't effect anyone unless you move or delete the file, and why would you do that? Also fixed an issue where only the last file tested was being logged in the Event Log even though they all would show up in the test window.

1.2 - Added Configuration Editor for definition files.

1.1 - Added "Force Applications to Close" option (e.g. shutdown.exe -F) so unresponsive applications will be forced to close when a shutdown operation is initiated.

system requirements::

ShutdownUnless is only designed for WINDOWS XP and 2003, any version. It may or may not work on other NT based OSes provided it has the appropriate version of Microsoft shutdown.exe in the path.

instructions::

INSTALLATION:
1. Run the setup.
2. ShutdownUnless.exe with no parameters to configure and test (will run automatically after setup finishes.)


USAGE INSTRUCTIONS:
1. Install, at the end of installation the application will start for an initial configuration. Browse for and add as many files as you need, such as access database files, quickbooks files, etc. Use the test button to see what would happen if you were actually running the app with it's parameters (see #2.)

NOTE: UNC path names will not work, if you must test for an open file across the network, you need to map some part of the path to a drive letter!

Be sure to test the app, and check the event log for a failure event (if one of your files was actually in-use, of course.) Note the Source: ShutdownUnless and the Event ID: 10177. Of course, this is a test, so your computer won't actually shut down if files are not in use!

2. Configure your shutdown batch or script to run ShutdownUnless.exe with a -s parameter to shutdown or a -r parameter to restart.

Here is a one line batch file example, which can be used in any shutdown script, which will restart if no files are in use. EX: %programfiles%\Foolish IT\ShutdownUnless\ShutdownUnless.exe -r

That’s it. Nothing more to do. Really.

license:

This software is licensed, however it is completely FREE for personal use under the terms of this license. A thank you email would be nice. Paypal donations may be accepted as an option one day, but currently I'm too lazy.

- Personal use is FREE only if you acknowledge that this program is provided with no warranties or guarantees of any kind, and that you (not John N. Shaw, not www.FoolishIT.com, not my web host, not your ISP, not your mother) and only you are held as the bearer of sole responsibility for any use or misuse of this software and any resulting damages in any form, monetary or otherwise. If you do not accept this policy but are still compelled to use the software, there is a small one-time licensing fee of 10 million dollars.

- Use in a business environment does require a different license. A license is currently obtained by contacting the author via the official website (you should be here already,) and license information is maintained solely by the author; I hope you will do it out of respect, (or to get a personalized copy.)

- There are no limitations, no trial versions, no included code for licensing/activation/etc., no ads, no nags, no 3rd party *ware of any sort included in this software or it's installer. This program is provided as-is, with no guarantees, no warranties, and no worries.

- Source code for this application remains the sole property of the author; this is at least until I can learn to code better and re-write it so that it isn’t not so embarrassing. I may open source it at some point after this. Don't count on it because I'm really lazy.

- Any use of this software requires that you accept the fact that I'm not responsible for anything you do with any software, including this app!

download:

* By downloading any of the following software, you accept the license above.

shutdownunless installer

No comments: