We have a program that, due to memory leaks in some of the screens, doesn't exit cleanly when the user quits. The problem is that this blocks the normal logoff procedure - you select logout and a few processes disappear but the user doesn't actually log off.
Since I'm unable to fix the program, I thought I'd use a script run at logoff to kill the process. I've verified the script kills the process if I run it by double clicking and have added the script to Windows Settings -> Scripts -> Logoff on my machine in gpedit.
Unfortunately it seems that the logoff scripts don't get run until all the processes have died, so it never runs.
Is there a way to make the logoff scripts run at an earlier point in the process? Or is there a better approach to the issue?
Have you tried the registry setting under HKEY_CURRENT_USER\Control Panel\Desktop AutoEndTasks set to 1? If that works you will not need the script.
You could use a program to log off such as http://www.karenware.com/powertools/ptstopper.asp that runs scripts before the log off.
add this to the end of your script
have them use this script instead of the normal logoff.
i am currently not sure how to make it run a script before processes quit, but can continue to look if this doesnt work. also, i didnt get a chance to test, but that should be the right syntax for the command. let me know if it needs some tweaks.
Perhaps try Microsoft's UPHClean service. Note this will only work on 2000/2003/XP http://www.microsoft.com/downloads/details.aspx?familyid=1b286e6d-8912-4e18-b570-42470e2f3582&displaylang=en
It's kind of funny, I think, that the problem you have is that the user never fully logs-out when they log out, so you write a script that says "kill this process on logout" but the script can't run because the user never logs out. You want the script to start when the user hits "log off" not when the user has finished logging off.
I'm not very savvy with VBScript or even the Windows API behind logging out, but I would suggest one of the following:
Find out if there is a separate event/trigger that is thrown when a user selects "Log Off" and have your script fire at that point. If this is easier said then done, I apologize, but it seems like the most obvious way to get what you actually had in mind.
Find out if there is a process that definitely quits after the user chooses Log Off (
explorer.exe
maybe?). This would only be a good idea if either the process you are trying to kill is not system critical or session critical, (or if the process you tie your kill script to IS system critical), as you wouldn't want the script to kill the process simply because the user closed something in the tray.I think the idea of having a log off script is pretty good, but I would suggest finding out if you can actually replace the "log off" button on the start menu with a button that launches this script. I know I've seen something similar in computer labs. But if you rely on users to remember to click the custom "log off" button on the desktop, and they can still get to the normal log off, that muscle-memory is only going to make everyone frustrated.