Running python script on when user unlocks windows machine

1

I have a python script , which I want to run , when user unlocks the machine ie; When users presses Cntl-Alt-Delete and enters username and password and logs in.

How can I do this ? . Is there any registry value , I can add that

pythonw.exe C:\myscript.py to that so that , it runs myscript.py everytime , user unlocks the machine ?

Jijoy

Posted 2011-03-31T08:27:46.103

Reputation: 179

Answers

1

You can use the Windows Task Scheduler (Vista and higher) or the Scheduled Tasks control panel (WinXP) to create a scheduled task that triggers "At logon" or "On workstation unlock." I believe such a trigger will cause the task to execute in the scenario you describe.

Mike

Posted 2011-03-31T08:27:46.103

Reputation:

Nope. I just tried and it didn't ran. – None – 2011-03-31T08:49:50.927

2There's also an "On workstation unlock" trigger. Give that a try. – None – 2011-03-31T09:14:17.580

1in windows xp ? – None – 2011-03-31T09:28:58.320

2No, I believe "On workstation unlock" may be limited to Vista and higher. There may be a way to achieve similar results on xp but it's probably not as straightforward. You might want to add "XP" to your original question (or the tags) if "XP" is the required platform. BTW, I just verified that "On workstation unlock" works as expected on Vista by having it send mail to myself. – None – 2011-03-31T09:47:14.040

0

you should check Schtasks.exe

Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer. Running Schtasks.exe without arguments displays the status and next run time for each registered task.

P2bM

Posted 2011-03-31T08:27:46.103

Reputation:

it can run only on logon and not on while user unlocks the machine. – None – 2011-03-31T08:49:05.857

check here http://technet.microsoft.com/en-us/library/bb490996.aspx in the "/sc" parameter there is a ONLOGON value that following their description should do what you need

– None – 2011-03-31T09:00:07.207

0

For Windows XP, use PyWin32 to:

  • win32gui.CreateWindow() an invisible window
  • call win32ts.WTSRegisterSessionNotification()
  • listen for WM_WTSSESSION_CHANGE window messages having wparam == WTS_SESSION_UNLOCK
    • lparam will be the session ID
  • An example implementation: wtsmonitor.pyw

If you want the script to work for multiple users, convert it to a service (win32serviceutil is handy for this); see wtsmonitor-svc.py at the above address.

user1686

Posted 2011-03-31T08:27:46.103

Reputation: 283 655