31.10.14

Conditional Shutdown:

10/31/2014





Conditional Shutdown:
I just found a batch code by which you can shutdown, restart, log off etc your computer with choice. This is an example of conditional batch programming and a part of advanced batch programming. In this program you have options to do what you want. You can understand this very easily if you have basic idea about conditional if statement. This is code for conditional shutdown, write this in notepad and save as anyname.bat and double click for run.

@echo off
color 0A
title Conditional Shutdown
:start
echo What would you like to do?
echo.
echo 1. Shutdown in specified time
echo 2. Shutdown now
echo 3. Restart now
echo 4. Log off now
echo 5. Hibernate now
echo.
echo 0. Quit
echo.
set /p choice="Enter your choice: "
if %choice%==1 goto shutdown
if %choice%==2 shutdown -s -f
if %choice%==3 shutdown -r -f
if %choice%==4 shutdown -l -f
if %choice%==5 shutdown -h -f
if %choice%==0 exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

:shutdown
cls
set /p sec="Minutes until shutdown: "
set /a min=60*%sec%
shutdown -s -f -t %min%
echo Shutdown initiated at %time%
echo.
set /p cancel="Type cancel to stop shutdown "
if %cancel%==cancel shutdown -a
if %cancel%==cancel cls
if %cancel%==cancel echo Shutdown is cancelled.
if %cancel%==cancel echo.
if %cancel%==cancel pause
if %cancel%==cancel exit

Written by

a computer geek and a junior compo programmer by interest and lecturer in accounting by profession. He got his MSIT, BBIT, and MBA in Community Development at Golis University - Burao and Fair Land University - Hargesia. He has an excellence work experience with Excel Accounting/Financial Accounting, AIS/MIS/FIS/Computerized Accounting. He also masters in Excel Programming, Access Programming not to mention that he is an IT Professional in Microsoft Studio and Visual Basic Programming , Web Development in "PHP, Joomla, Wold Press. He also trained in Networking, Hardware, IT Security all in all Maxbuub has a limit let potentials and skills and he chooses to share all of that an more in this blog. Facebook: https://www.facebook.com/MrBura0

0 comments:

Post a Comment

 

© 2014 Hacks And Security . All rights resevered. Designed by Templateism

Back To Top