Site icon Kommands.com

Using a Batch File to Lock, Sleep, Restart, and Shut Down a Computer

A batch file is a simple text file that contains a list of commands that are executed in sequence. Batch files are useful for automating tasks and can save you a lot of time and effort. In this article, we will show you how to use a batch file to lock, sleep, restart, and shut down a computer.

To lock a computer using a batch file, you can use the following command:

rundll32.exe user32.dll,LockWorkStation

This command will lock the computer and require the user to enter their password to log back in.

To put a computer to sleep using a batch file, you can use the following command:

%windir%\System32\rundll32.exe PowrProf.dll,SetSuspendState

This command will put the computer into sleep mode, which allows you to quickly resume your work from where you left off.

To restart a computer using a batch file, you can use the following command:

shutdown /r

This command will restart the computer and close all programs.

To shut down a computer using a batch file, you can use the following command:

shutdown /s

This command will shut down the computer and close all programs.

To create a batch file, follow these steps:

  1. Open a text editor such as Notepad.
  2. Type the desired command(s) and press Enter after each one.
  3. Save the file with a .bat extension. For example, you can save the file as “lock.bat” or “sleep.bat”.
  4. Double-click on the batch file to execute the command(s).
Exit mobile version