Blocking a log off request with Python
I have some software that occasionally logs me off automaticly. I want to block this, so I won't be logged off (windows 7). Are there a way to block log off requests using Python? If so, then how and if not; are there any other solutions?
Looks as if there's a possible solution in an MSDN article.
What you'd have to do is write a simple Windows application which handles the WM_QUERYENDSESSION event, and returns FALSE, then, in theory, as long as that application is running, the system won't log you out. It's possible that just leaving open an instance of notepad.exe with an unsaved file in it would achieve the same thing.
It, might, however, cause all other applications to terminate, so, if that's undesirable, you'd have to intercept the call to ExitWindows from softXpand, which is much more complicated.
Some security products like Comodo Internet Security will allow you to run an application in a sandbox, such that you can intercept and deny certain system calls, which might work.
See also: this question.