system
How to lock Windows by running a file (or command)
by Tricky on May.20, 2008, under system
If you’ve ever needed to lock your windows up while you are away for a while (ex. jump out really quick out of your working desk) you probably know the shortcut WINKEY+L – this works in all windows versions. You have probably thought if you can make it locked by starting a file this might be your solution. Why do you need to lock your computer with a command (or starting file)? Here is two major reasons:
- A user has to be logged on so an application to be started (Torrent client, simple FTP/HTTP server, etc);
- You might want to lock the computer in certain cases (after an application ends, at exact time and so on);
- Of course there is more cases you need to lock you windows session…
Well, if you use a simple windows command with particular options (which is documented in windows documentation) you can lock your session:
%windir%\system32\rundll32.exe user32.dll, LockWorkStation
This works no matter where your windows installation is.
So if you need a command the above line is for you. But if you need a file to be run you can create one by following this steps (this is for Vista, in all other “modern” versions – Windows NT/2000/2003/XP is similar, I haven’t tested it in Windows 95/98/ME though):
- Right click on your desktop and choose NEW then SHORTCUT;
- Paste this: %windir%\system32\rundll32.exe user32.dll, LockWorkStation in the field “Type the location of the item:”;
- Click NEXT then name the shortcut as you like (ex. LockWin), then hit FINISH.
That’s it. If you don’t like the icon of the shortcut you can change it in the well known way – right click on the shortcut, hit PROPERTIES, choose SHORTCUT tab and press CHANGE ICON button. Then choose an executable file (or DLL) to take the icon from. There is a lot if icons in Vista in this file: “%SystemRoot%\system32\imageres.dll”. And for all windows versions you can use “%SystemRoot%\explorer.exe”. You can use custom icon (EXE,DLL) file too.
Hope this will solve some issues.