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.
October 29th, 2008 on 2:18 am
Good for people to know.
February 24th, 2009 on 6:14 am
Thank you!
March 16th, 2009 on 2:57 pm
Greatings,
Not sure that this is true:), but thanks for a post.
Have a nice day
Pett
March 16th, 2009 on 3:14 pm
Well, all I did is an Internet research – these are all windows- implemented functions. I tested and actually use it all the time. When you try and it doesn’t work – share it so I can help.
March 22nd, 2009 on 7:40 am
Hi there,
Thank you! I would now go on this blog every day!
Thank you
Eremeeff
June 15th, 2009 on 9:39 am
Hi, very nice post. I have been wonder’n bout this issue,so thanks for posting
June 16th, 2009 on 12:27 pm
Hello. I think the article is really interesting. I am even interested in reading more. How soon will you update your blog?
July 7th, 2009 on 2:52 am
Hi! I like your srticle and I would like very much to read some more information on this issue. Will you post some more?