Programmatic alternatives to Windows-L keyboard shortcut (SwitchUser / LockWorkstation)
Posted by jpluimers on 2012/06/07
On Windows, the keyboard shortcut [WayBack] Windows-L will lock your workstation and when [WayBack] Fast User Switching is enabled – and when your (corporate) policies allow it – shows your Switch User screen.
First of all, there is [WayBack] TSDISCON (which I found thanks to [WayBack] this thread). It is meant to disconnect a terminal services session, but when you are logged in on the console, it just locks your workstation.
It is small (about 20 kilobyte) and [WayBack] has been there since Windows 2000.
Then there is the [WayBack] LockWorkStation function that does the same.
Lot’s of people think you can call LockWorkStation using rundll32.exe. As per Raymond Chen: [WayBack] (404) Don’t do that: it has a different parameter count and different calling convention than [Archive.is] rundll32.exe expects (note that in Raymond’s article, the last link is broken).
So now you all go upvote [WayBack] the TSDISCON answer and downvote the ruldll32.exe LockWorkStation
answers on this [WayBack] SuperUser.com question.
–jeroen
PS: [WayBack] Rob van der Woude published a list of Terminal Server commands including TSDISCON.
Leave a Reply