Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

5 Answers 5

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.

share|improve this answer
    
I'll try that when I'm in work tomorrow. –  robertc Jan 27 '10 at 23:48
    
Unfortunately that doesn't seem to make any difference. –  robertc Jan 29 '10 at 13:46
add comment

You could use a program to log off such as http://www.karenware.com/powertools/ptstopper.asp that runs scripts before the log off.

share|improve this answer
    
It's unlikely I'll be able to persuade them to install extra software to do this, but this may be useful as a last resort, thanks. –  robertc Jan 27 '10 at 23:49
add comment

add this to the end of your script

Set strComputer = "."

Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")

for each OpSys in OpSysSet
    OpSys.Win32Shutdown 0
next

WScript.Quit(0)

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.

share|improve this answer
1  
You have apparently made the assumption that the logoff script is written in whatever language that snippet is. Assumption is the mother of all stuff-ups. –  John Gardeniers Feb 3 '10 at 19:11
    
He looks to have made the, not unreasonable, assumption that the language of the logoffscript is VBScript, presumably since I tagged the question 'vbscript'. My question is how do I replace the normal logoff, is there some easy AD driven way to do this? –  robertc Feb 4 '10 at 14:26
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.