Sign in to follow this  
Followers 0
tankmann

OnAutoItExit() during Shutdown isn't be processed

4 posts in this topic

Hi all,

I've written a little Login-GUI that's permanently on top to have a windows-independent Login.

It has to work with NT4 and XP.

The Script prevents starting some programs while not logged in.

It runs as a service.

To ensure that the login-GUI is always available, I've written a second small script that just checks if the login-GUI process exists and in case of the non-existance it will be restarted. This runs as a service,too.

So far so good - that works.

But when Windows is shutting down, my second process always tries to restart the login-GUI - that results in a lot of error messages from Windows.

So I tried the following within the code of my Login-GUI to prevent a restart in case of a shutdown:

Func OnAutoItExit()
If @exitMethod = 4 Then
Run("net stop Login-restarter","",@SW_HIDE)
Endif
EndFunc

Unfortunately, this doesn't work.

Has anybody any idea how to solve that?

Share this post


Link to post
Share on other sites



Does anything run during your onexit event?

Just trying to see if it's that the event isn't running or if your net stop function isn't working.

Maybe when windows is shutting down the service required for 'net' commands to work has already stoped?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try this..

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

While 1
    sleep(10)
WEnd

Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
    ProcessClose("the other process that is relaunching this app.exe");or the net stop thing you posted above
    RunWait("net stop Login-restarter","",@SW_HIDE)
    Return True
EndFunc

Edit: Also you say you have a process that watches your main app, is this any easier http://www.autoitscript.com/forum/index.php?showtopic=48614

Edited by ChrisL

Share this post


Link to post
Share on other sites

Try this..

$WM_QUERYENDSESSION = 0x0011

GUICreate("ShutDownNotificationGui")
GUIRegisterMsg($WM_QUERYENDSESSION, "_ShutdownInitiated")
GUISetSTate(@SW_HIDE)

While 1
    sleep(10)
WEnd

Func _ShutdownInitiated($hWndGUI, $MsgID, $WParam, $LParam)
    ProcessClose("the other process that is relaunching this app.exe");or the net stop thing you posted above
    RunWait("net stop Login-restarter","",@SW_HIDE)
    Return True
EndFunc

Edit: Also you say you have a process that watches your main app, is this any easier http://www.autoitscript.com/forum/index.php?showtopic=48614

Thanks,

that's exactly what I needed :-)

Works perfectly!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0