| Member with 165 posts. THREAD STARTER | | Join Date: May 2008 Experience: Beginning Advanced | |
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. |