Jump to content

OnAutoItExit() during Shutdown isn't be processed


tankmann
 Share

Recommended Posts

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?

Link to comment
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

Edited by ChrisL
Link to comment
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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...