Sign in to follow this  
Followers 0
skipperpoop

Terminating Script Before Shutdown

5 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

;~ 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]

Share this post


Link to post
Share on other sites

Yea, I tried that one already :) . I think windows might use another process for its shutdown, while shutdown.exe is for manual shutdowns, shutdown shortcuts, etc.

Share this post


Link to post
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[/quote]

Share this post


Link to post
Share on other sites

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.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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