Read Mode
Default

Batch Script to Lock Computer | How to Lock PC From Notepad / CMD?

Lock Computer with CMD: Although You can automate many operations regarding system log-on - using the Shutdown command in CMD. But, One of the most essential requirements of Locking The System out is not provided in the pack. So, Directly there is no command to simply LOCK Computer. So, it is very difficult to make a batch file to lock computer windows. But, You can do the trick - combining few commands. Let's have a look.
What is CMD Actually? | Batch Basics | By kvc
Batch Script to Lock Computer | How to Lock PC From Notepad / CMD?
Batch Script to Lock Computer | How to Lock PC From Notepad / CMD? | Windows 10 Lock Screen

How to Lock PC From Notepad / CMD?

You need to Use the utility that comes with the windows by default (inbuilt command) Called, "Rundll32.exe". And, Provide another utility that comes with windows - "User32.dll". You will find both these files in the "C:\Windows\system32" Folder. Just Provide the 'LockWorkStation' Command from the dll. And, As you'll press Enter. (or execute it in your Batch File) You'll find your PC will be locked. The Command ...
Rundll32.exe user32.dll LockWorkStation

 Alternative Methods

Batch Script to Lock Computer | How to Lock PC From Notepad / CMD?
Batch Script to Lock Computer | How to Lock PC From Notepad / CMD?
Although, you can get the same thing with many other methods which allows you to send the combination of Keys as Windows+L. But, that will require multiple steps (and also note that - VBS don't allow to simply send the Windows Key) So, we still think - This method is little hard to learn - but, it good and easy to use for the batch programmers.
Must Read: Mouse Buttons Swapping by Batch Scripting

From Editor's Desk

What do you think about this method of Locking your PC via CMD? If you have an any better method or you want to share your way of achieving this faster and efficiently in Windows. Please Feel free to ask or share your thoughts in the comments. We'll really like to read them. 

You can also share your work in the field of Batch programming to publish on this Batch blog. We'll publish it on the blog with your name. Thanks for faith and time. We'll see you in the next article.

Keep Learning, Keep Sharing...
Be Happy, Spread Happiness...

4 comments:

  1. Hello kvc,
    Is it okay if you would write a full tutorial on how you were able to control that lightbulb using batch and arduino (especially wirelessly if you tried that too):)

    ReplyDelete
    Replies
    1. Yeah, Looking forward to write about it (as I'll go forward in publishing/posting about the series parts). I'll try to briefly explain every aspect of the project.

      NOT TRIED the Wireless concept... But, I'm quite sure that it will work too - maybe that will require little extra effort. :)

      Delete
  2. kvc bro please make an ping of death batch file..

    ReplyDelete
    Replies
    1. You can do multiple Ping Requests (in multi-threading mode) for infinite number of times (using -t switch). And, Create an illusion of ping of Death Attack. :)

      But, with today's security measures - The Remote PC may stop accepting the data or other safety guidelines may prevent it. But, it doesn't mean - we should stop trying! :)

      Delete

Powered by Blogger.