Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:\ to that so that , it runs everytime , user unlocks the machine ?

share|improve this question

migrated from Mar 31 '11 at 16:39

This question came from our site for professional and enthusiast programmers.

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.

share|improve this answer
Nope. I just tried and it didn't ran. – Jijoy Mar 31 '11 at 8:49
There's also an "On workstation unlock" trigger. Give that a try. – Mike Mar 31 '11 at 9:14
in windows xp ? – Jijoy Mar 31 '11 at 9:28
No, 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. – Mike Mar 31 '11 at 9:47

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 at the above address.

share|improve this answer

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.

share|improve this answer
it can run only on logon and not on while user unlocks the machine. – Jijoy Mar 31 '11 at 8:49
check here in the "/sc" parameter there is a ONLOGON value that following their description should do what you need – P2bM Mar 31 '11 at 9:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .