• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

Force user to close application before shutting down or logging off the system


How can I force users on the netwoek to close a running application before they shutdown or log off the pc? The network is a windows 2000 active directory enabled with clients running windows xp. This has become quite important because we run a bespoke application that gets corrupted transactions because despite constant warnings users do not bother to close down the running application properly and just go to start --> shutdown. Is there a script or something that can do this??? Also to be able to display a warning message would be very helpful.

Many thanks
  • 6
  • 3
  • 2
1 Solution
First open gpedit.msc and drill down to either

Local Computer Policy|Windows Settings|Scripts (Startup/Shutdown) (this to be used for a shutdown script)
User Configuration|Windows Settings|Scripts (Logon/Logoff) (this to be used if you want to do this on changing users)

then click on Shutdown and add the link to your message like "notepad c:\path\warning.txt"

Right here you could add a program stopper too.

I think that putting warning info in the logoff and shutdown scripts may be a little too late - but I'm only spouting off the top of my head here.

My idea would be to remove the shutdown and logoff buttons by policy, and replace them with shortcuts to a vbscript or batch file. The batch file could do something like:

tasklist | find /i "yourapp.exe"
if errorlevel 1 goto :notloaded
Echo You haven't exited yourapp!
Goto :EOF

REM Logoff
shutdown -l -f
REM OR Shutdown
shutdown -s -f

I'm sure you could do the same in VBScript fairly easily.


@ Wallsy, yep you are right with the warning, my mousewheel was broken I had to fix that.

Then a used printer arrived, to replace my broken one, well I messed that up too.

Now the "new" is working again, since they are both the same modell, I try to repair the older too (in the meantime they  both showed the same failure), so this looks promissing.

Ok enough excuses.

You got a nice idea with this script.

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Thanks Tolomir,

I've just had a "nothing went right" day, so I empathise!


ramrod1979Author Commented:
Tolomir while I can appreciate that you may have certain issues with other aspects of your computing setup there is no need to hijack the question and have a personal conversation over the top of a question. Can you just not send wallsy your e-mail address or messenger id and talk that way?? Please don't do this!!??
Ramrod1979, I haven't tried to hijack your question, but had little time to respond.

Up today, I still cannot suggest more to you than to follow Wallsy's idea:

"Ok enough excuses. You got a nice idea with this script."

So you should try it that way.

1st: disable the logoff button
2nd: create a icon shortcut to a batchfile, that checks if that particual application is still running, if yes: Show a Warning message, if not (i.e. program is already closed) shutdown properly.

I don't think you have to use a vbscript, but a simple batchfile would be enough.

All you have to do is to replace "yourapp.exe" with the real name of the program, save the script in a front directory like c:\windows as shutdown.cmd

just start cmd.exe (from Start->run) and try to run the script.

c:\windows\shutdown.cmd <Enter>


 Disable logoff buttons of Start menu and NT security dialog (alt-cntl-del).

Key: Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
Name: NoLogoff
Value: 1 disable

Save this to a "nologoff.reg"

<<<<<<<<cut here>>>>>>>>>>>>>>
Windows Registry Editor Version 5.00

<<<<<<<<cut here>>>>>>>>>>>>>>

Has to be run once by each user (put it in autostart)
This looks a bit more comfortable:


Policy Settings for the Start Menu in Windows XP

You can use the Group Policy editor (Gpedit.msc) under the following location to configure Start menu features:
User Configuration \ Administrative Templates \ Start Menu and Taskbar
Note: Except when noted, all of these registry settings are under the following registry key:
The registry entries are DWORD values. A value of 1 is enabled, and a value of 0 is disabled.

Policy:Disable Logoff on the Start Menu
Description:Removes the "Logoff" button from the Start menu and prevents
users from adding the Logoff button to the Start menu.
Registry Value:"StartMenuLogoff"

Policy:Disable and remove the Turn Off Computer button
Description:Removes the "Turn Off Computer" button from the Start Menu and
prevents shutting down Windows using the standard shutdown user interface.
Registry Value:"NoClose"

Yeah, I meant to say all that stuff too! But the batch file was as far as I got...


ramrod1979Author Commented:
..apologies about that. The last comment from Tolomir was more helpful. Many thanks Tolomir and I did not mean to be so horrible. Have a great day.

ok, thank you

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now