Jump to content

Terminating Script Before Shutdown


Recommended Posts

I'm trying to figure out how to terminate a script right before a user shuts down the computer. I've tried looking for the shutdown process so I could use If ProcessExists, but I never found it. I also thought maybe the shutdown window had a name, then I could use If WinExists, but I had no luck with that either. I'm not real knowledgeable when it comes to programming, so any help would be much appreciated.

Thanks

Link to comment
Share on other sites

;~ Your code in here
While 1
        If ProcessExists("shutdown.exe") Then
            Exit
        EndIf
WEnd

Edited by Daniel W.

--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Link to comment
Share on other sites

I've posted a while ago on the same matter...You have to intercept a message that is sent to all processes...

Global $WM_QUERYENDSESSION=0x0011
Func InterceptShutdown($hWnd,$msg,$w,$l)
MsgBox(0,"","Shutting down")
EndFunc
GUIRegisterMsg($WM_QUERYENDSESSION,"InterceptShutdown")
while 1
wend
Quote

Together we might liveDivided we must fall

 

Link to comment
Share on other sites

  • Developers

Func OnAutoItExit ( )

...

EndFunc

Remarks

Inside the function, @ExitCode can be used to retrieve the code set by the exit statement.

The mode of exit can be retrieve with @ExitMethod.

0 Natural closing.

1 close by Exit function.

2 close by click on exit of the systray.

3 close by user logoff.

4 close by Windows shutdown.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...