As discussed in my previous post I have installed VirtualBox recently. But after installing VBox i found that the Windows key or the super key (called in Unix environment) is not working anymore when the virtual machine is running. That is the key used as a shortcut (window key + L) to lock my PC.
So I found another tweak to lock pc when your windows key is not working or if you need this in any of your script.
If you type the following line in your command line, then the PC will be locked instantly.
rundll32.exe user32.dll, LockWorkStation
This works for both Windows XP and Windows Vista.
Hope this helps