Friday 7 July 2017

[Life Hack] Shutdown Menu using BATCH File

Shutting down your pc/laptop using the conventional means can be a little tiresome for some.
To help you ease this process, I have brought to you a convenient method which will not only save your time but also be fun to learn.





Steps

  1. First of all you need to create a batch file. To do this, create a text file and change its extension to .bat (alternatively, you can save the text file using the same extension)
  2. Copy the below given command into the batch file.



@echo off
:start
echo 1. Shutdown
echo 2. Restart
echo 3. Exit
set /p ch=

if %ch%== 1 goto shutdown
if %ch%== 2 goto restart
if %ch%== 3 goto exit
goto exit2
:shutdown
echo Set time:
set /p time=
echo Windows will shutdown in %time% seconds...
pathping localhost -q 2 -p 400 > nul
shutdown.exe /s /t %time%
goto exit
:restart
echo Set time:
set /p time=
echo Windows will restart in %time% seconds...
pathping localhost -q 2 -p 400 > nul
shutdown.exe /r /t %time%
goto exit
:exit2
echo Wrong choice!
goto start
:exit


Thats it. Open the file and you're good to go.

Legend

-s indicates that the shutdown application is actually going to shut down the computer

-f forces all running programs to close

-t 00 indicates no delay in execution (this does not apply to the hibernate batch file)

-r indicates a restart

/h indicates hibernation

Also:

-t xx timeout period (xx is number of seconds)

-l is logoff [L] (can only be used by itself)

-a is to abort an already initiated sequence

-i opens the shutdown GUI

-m \\computername name of computer that action is applied to (using your computer name is
same as not putting it in and may be configured to shut down a local
remote computer though I am not sure how

-g restarts computer and any registered applications

-p turn off computer with no time-out or warning (same as ..shutdown -s -t 00)

-e document reason for unexpected shutdown

-c "comment" comment on the action

-d [p or u]:xx:yy reason; p indicates it is planned; u indicates it is user defined; xx and yy are
reason ID numbers (u:0:0 is easiest, it means other and unplanned)

No comments:

Post a Comment