Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Windows XP Windows XP
Search Search
Search for:
Tech Support Guy > > >

Solved: Logoff Script in Windows XP Home


(!)

des000's Avatar
des000 des000 is offline
Member with 234 posts.
THREAD STARTER
 
Join Date: May 2008
Experience: Beginning Advanced
07-Jul-2008, 04:23 PM #1
Solved: Logoff Script in Windows XP Home
I need a free program to run a logoff script in Windows XP Home or Windows XP Professional. It has to not depend on the network, so no netlogon share or something.

I've ended up being made aware of several ways to do this from searching, but I can't find an already built program that does this. There's HSLAB shutdown folder lite, but it has quick shutdown. I just want a logoff script, no other changes to Windows XP. There's group policy which is perfect, but doesn't support Windows XP Home. I don't want to get it to run on Home, that might be illigal.

You can create a script to shutdown and execute that script instead of shutdown, but I just want to execute a regular shutdown or whatever and have the program run. There's a NEW GINA program, but I don't want the rest of that New GINA, just the logoff feature if I were to use it.

Some programs shut down after a certain amount of time, and then run a logoff script before the computer shuts down, but I don't want timed shutdowns.

I could write a program to wait for a logoff event and then execute a script from the background, which would work I think if I could find a program to do that. It would also seem to work fine as I've saw searching to have a system tray icon that just waits until the icon is gone and then runs a script, but I can't find a program to do that already, just a thing that says how it works. Do you know any program that exists for free that does this?
Aitrusskyy's Avatar
Aitrusskyy Aitrusskyy is offline
Computer Specs
Member with 272 posts.
 
Join Date: Jun 2008
Experience: Advanced
07-Jul-2008, 04:58 PM #2
Squashman's Avatar
Trusted Advisor with 19,645 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
07-Jul-2008, 06:57 PM #3
Could you clarify something for me?
You just want a way to run a script that will run when the user performs a log off?
Or you want a script to force a logoff?
des000's Avatar
des000 des000 is offline
Member with 234 posts.
THREAD STARTER
 
Join Date: May 2008
Experience: Beginning Advanced
07-Jul-2008, 07:20 PM #4
Thanks for replying. It's the second one I'm looking for. I'm looking for a way to run a script when the user performs a log off in Windows XP Home, but that works also in Windows XP Proffessional/Media Center Edition.
Aitrusskyy's Avatar
Aitrusskyy Aitrusskyy is offline
Computer Specs
Member with 272 posts.
 
Join Date: Jun 2008
Experience: Advanced
07-Jul-2008, 07:34 PM #5
No problem. From both those links I derived that in order to do what is in the second link, you need to download the package listed in the first link to obtain the winexit.scr file.

Hope it works for you.
Squashman's Avatar
Trusted Advisor with 19,645 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
07-Jul-2008, 07:41 PM #6
I don't have an XP Home Machine to test this on, but could you check to see if you have this Registry key.
Code:
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff
Squashman's Avatar
Trusted Advisor with 19,645 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
07-Jul-2008, 08:18 PM #7
There is a free trial of this program. See if it will work for you.
http://www.snapfiles.com/get/activeexit.html
des000's Avatar
des000 des000 is offline
Member with 234 posts.
THREAD STARTER
 
Join Date: May 2008
Experience: Beginning Advanced
09-Jul-2008, 10:42 PM #8
Looks as if after lots of research, autoit is the only closest thing I've found so far. Here's the current autoit code:

Code:
shutdown_preparation()
While 1
    Sleep(1000)
WEnd

Func OnAutoItStart()
 AutoItSetOption("TrayIconHide", 1) 
EndFunc
Func OnAutoItExit()
 ;If @ExitMethod = 3 Then execute_logoff_script()
 ;If @ExitMethod = 4 Then execute_shutdown_script()
EndFunc
Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
 $close = 0x00000001
 $logoff = 0x80000000
 $shutdown_or_restart = 0x0
  
 
 ;If $LParam = $logoff Then execute_logoff_script()
 ;If $LParam = $shutdown_or_restart Then execute_shutdown_script()
 return True
EndFunc
Func _DoShutdownCleanup($hWndGUI, $MsgID, $WParam, $LParam)
 $close = 0x1
 $logoff = 0x0
 
 If $LParam = $logoff Then execute_logoff_script()
 If $LParam = $close Then execute_shutdown_script()
  
 return 0
EndFunc

Func shutdown_preparation()
 $WM_QUERYENDSESSION = 0x0011
 $WM_ENDSESSION = 0x0016 
 
 
 DllCall("kernel32.dll", "int", "SetProcessShutdownParameters", "long", 0x3FF, "long", 0) ;makes this program get a "Shutdown" message before other programs, but after the system
 GUICreate("ShutdownNotificationGUI",1,1) ; dummy gui for shutdown message
 GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
 GUIRegisterMsg($WM_ENDSESSION, "_DoShutdownCleanup")
 GUISetSTate(@SW_HIDE)
EndFunc
Func execute_logoff_script()
 FileDelete("C:\BATCH\logoffwait.tmp")
 
 While Not FileExists("C:\BATCH\logoffwait.tmp")
  sleep(1000)
 WEnd
EndFunc
Func execute_shutdown_script() 
 execute_logoff_script()
 FileDelete("C:\BATCH\shutdownwait.tmp")
 
 While Not FileExists("C:\BATCH\shutdownwait.tmp")
  sleep(1000)
 WEnd
EndFunc


For now, until this file is ready, I'll leave out the 2 services I'd used to run the scripts. I could just run the scripts in the autoit code, except for Windows XP won't seem to let me at the time I need to. It gives a too late message of a type, so they need to run as services all the time. If they run all the time, but are NOT services, then it won't work. The processes have to survice the logout, appearently.

Well, if I uncomment the code for the WM_QUERYENDESSION part, it acutally seems to work just fine. However, if shutdown.exe were to be called, it doesn't honor the WM_QUERYENDSESSION request. Therefore I have issues as shutdown.exe is used frequently. So do you know any code I guess to hook the Windows shutdown function that all types of shutdown requests would always use perhaps? Then no matter how I shutdown, it would work. Maybe that's the answer. However, unless you can point to both a free tool to compile and run the code you know of, assuming you know of code that will do that, I'm stuck right there anyway.

I could replace that function with very simple code. I could simply ensure that my scripts are run, and then pass on code to the default Windows XP code. That way it would add code, but not replace any code.

In edition, if I didn't do it that way, maybe I could simply use a type of GINA? I tried once a NEW GINA thing that somebody made, but again, if I did that, that would be fine, but I don't want to change anything else, I just want to add code for a logoff and shutdown script. After that task, if I replaced any Windows XP code, I want to just add that, and then call the origional code. I don't want to try to rewrite the Windows XP code at all. I don't want to figure out how it shuts down and re-invent the wheel on Windows XP. I don't want either to replace GUI part of the GINA if I do that either.

Sorry it took so long to post back, but I had just found the autoit script and was tweaking it, and it worked fine up until this point. The active exit program is not freeware, exactly, and I don't quite like the interface, but thank you.

Looking at the HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts\Logoff key, it is just what I want to do, unfortunately I checked, and I just double checked too. It doesn't exist on Windows XP Home. If it did exist, even manually, I'd have absolutely no trouble. I whish it existed!

So it's not going to be a Microsoft tool, but a 3rd party tool that does this I guess! Well, I think I can get even a little tiny bit further too, IF I'M RIGHT. From my searches, it appears that Advapi32.dll contains the shutdown function I might need, and is located in C:\WINDOWS\system32. If that's really true, then I need a replacement Advapi32.dll that would execute the logoff code I need and then continue to the origional code. Well, that's all the new information I know.
des000's Avatar
des000 des000 is offline
Member with 234 posts.
THREAD STARTER
 
Join Date: May 2008
Experience: Beginning Advanced
09-Jul-2008, 10:45 PM #9
Oh! I guess what I'm wanting this for might help finally at this point. I've heard of "Roaming Profiles", and I desire a custom roaming profile solution that works in a workgroup and makes sure that the profiles are copied correctly, unlike Windows XP. I've determined that this has to happen at logoff, and I can't use task scheduler to handle it every so often. I want it only at logoff. Unfortunately, this takes a batch file. I've found some cool synchronization tools, but it has to be command line so I can set it up in the blink of an eye on a machine in batch mode, plus it has to be at logoff. No other time will work.
des000's Avatar
des000 des000 is offline
Member with 234 posts.
THREAD STARTER
 
Join Date: May 2008
Experience: Beginning Advanced
10-Jul-2008, 03:01 PM #10
It's become pretty clear to me that unless the Windows shutdown code that's common between the GUI and the shutdown.exe command, and which is also common to every program that does not shut down completely according to it's own power (by completely bypassing the OS), is hooked to make the code run properly, then it simply cannot be done. There's no reliable way to accomplish it, I guess. Does anybody have code to do this? I do want to keep the Windows code, just add to it, if not, I guess it's simply impossible. All shutdown script programs seem to work the same way. They don't execute unless the GUI is told to. This is clearly evidence of a very poor shutdown.exe program, plus a completely poor shutdown procedure for the OS, and bad shutdown API, however unless there's the proper code written by someone, it simply appears to be impossible.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑