29 July 2015

Shutdown, Restart, Log off Your Computer Using Command Prompt

This Trick is all about batch programming and cmd commands. In this tutorial I am Going To tell you how to restart, shutdown and log off your computer using command prompt.

In next step we will make a batch (“.bat”) file so that you can send it to your friends for prank purpose or save it for your future use.

Shutdown your computer using command prompt and batch program

However this tutorial is not just a trick or a pranks but a useful tool for you by which you can schedule you computer restart, shutdown and log-off commands. i.e., you can fix a limited time period for which you want your computer to work on.

Adding above features this tutorial has one more amazing thing by which you can display the reason for your computer shutdown. Now Lets Begin to code !

Command Prompt Way To Shutdown, Restart Or Log-off

Steps –

1. Go to search menu and search for “cmd.exe

2. Now open it and a black box will appear. I think you are friendly with this windows or if not then don’t panic we will introduce you with Him.

3. This time you need to write few commands inside command prompt. Commands are based on the operation/task you want to execute.

For Shutdown:

shutdown /s

Shutdown /s commands to shutdown pc using command prompt

For Restart:

shutdown /r

For log-off:

shutdown /l

For Hibernate:

 shutdown /h

More Commands !

- For Text/Comment To Display  (Advance Tutorial +) :

Shutdown /c “your comment here”

Note: you comment should be less than 512 characters. This comment command will not work independently, You should add this command in  your shutdown, restart, log-off or hibernate commands as follow.

Example For Shutdown :

Shutdown /s /c “Bye I am Tired NOW”

You can change “s” with “r”, “l”, or “h” of your choice. The above command will shutdown your computer with text showing “Bye I am Tired Now”. You can change comment text as you want. For example you can write “You are hacked” if you want prank with your friend. etc etc.,

- To Set Your Time For Shutdown (Advance Tutorial +):

Shutdown /t xxx

Replace xxx with the seconds after which you want to shutdown.

Note: xxx should be in seconds.The default is 30 sec. The valid range is 0-315360000 (10 years)

This Command work same as comment command and will not work independently. So add this command with others like shutdown etc., as follow.

Shutdown /s /t 300

The above command will shutdown your computer within 300 seconds.

- How To Use Shutdown + Comment + Time Commands simultaneously

Use Below code snippet and write it in cmd.

Shutdown /s /t 300 /c “your comment”

All Commands Related To Shutdown

4. Choose any of the command above As per your choice and write in command prompt box. After that press enter and you had done.

How To Abort Shutdown ?

Its very simple to abort/cancel windows shutdown .Just use below command in cmd.

Shutdown /a

This command will help you only when, if you are using “/r” , “/s” , “/h” , “/l” commands with “/t” , Otherwise your window will shutdown randomly.

Enjoy !

Batch Program For Shutdown, Restart OR log-off

Batch program is nothing but a program which work on cmd commands. The file extension type is “.bat”.These programs can be easily created with the help of notepad.

So why You need Batch program ?

Batch program will definitely make your task easy, especially when you are going to try this trick for your daily use. Using This program, you don’t need to type any shutdown commands. Sit beside and just open program, choose the function that you want to execute and you have done.

Lets Begin !

1. Go to search menu and search for notepad. Open it.

2. Copy below code in notepad :

@echo off
title Shutdown PC
color 0a
echo -------------------------------------------
echo Program Name shutdown PC
echo -------------------------------------------
echo This Program is created By Vivek Chaudhary
echo -------------------------------------------
echo please select below option :
echo -------------------------------------------
echo 1. shutdown PC
echo 2. restart PC
echo 3. Log-off PC
echo 4. Hibernate PC
echo 5. Shutdown With Time Limit And Message
echo 6. Restart With Time Limit And Message
echo 7. Abort A System Shutdown
echo ------------------------------------------
set /p input= Select No. Of Your Choice:
if %input%== 1 goto shutdown
if %input%== 2 goto restart
if %input%== 3 goto logoff
if %input%== 4 goto hibernate
if %input%== 5 goto STM
if %input%== 6 goto RTM
if %input%== 7 goto abort
if any %input%== goto wrong
echo Window is shutting down!
echo wait !
shutdown /s /f
echo Window is restarting down !
echo wait !
shutdown /r /f
echo Window is logging-off !
echo wait !
shutdown /l /f
echo Window is hibernating !
echo wait !
shutdown /h /f
set /p time=choose time in seconds :
set /p com=write comment here:
echo wait !
echo windows is Shuting Down !
shutdown /s /f /t %time% /c "%com%"
set /p time=choose time in seconds :
set /p com=write comment here:
echo wait !
echo windows is restarting !
shutdown /r /f /t %time% /c "%com%"
echo aborting shutdown/restart
echo wait!
shutdown /a
echo you choose wrong option !
echo choose again !
goto menu

3. Now go to “file>save as” and locate the path where you want to save your program. Name your program as “shutdownProgram.bat” and choose file type as “all type (*.*)

Shutdown Computer Using Batch Program

Make sure you have used “.bat” after your program name because it is batch file extension type. If you forget to write “.bat”, you program will not work.

Shutdown Computer Via Batch Program Preview

Now you had successfully completed your task. Just go to program and have a look at it. Choose the task that you want to execute and Enjoy !