Batch File


A batch file is a type of script that contains a list of commands. These commands are executed in sequence and can be used to automate processes.Batch files are run by the COMMAND.COM program, which is part of DOS and Windows. Therefore, batch files can only be run within the Windows operating system. Macintosh and Unix have other scripting tools, such as AppleScript and Unix shell commands, that can be used for similar tasks. Because batch files contain executable commands, it is important not to open unknown batch files on your hard disk or in e-mail attachments.

It is a text file containing a series of commands to be executed by the command interpreter.

file extension for batch file——  .bat , .cmd , .btm

Simple example for batch file—–

This example batch file displays “Hello World!”, prompts and waits for the user to press a key, and terminates.

@ECHO off
ECHO Hello World!
PAUSE

To execute this,first save this file with file extension .bat in notepad.This file is called bath file.
After execution this will be displayed like this–

Hello World!
Press any key to continue . . .

EXPLANATION—–
The interpreter executes each line in turn, starting with the first. The @ symbol at the start of the line turns off the prompt from displaying that command. The command ECHO off turns off the prompt permanently, or until it is turned on again. Then the next line is executed, the ECHO Hello World! command outputs Hello World!, as only off and on have special functions. Then the next line is executed, the PAUSE command displays Press any key to continue . . . and pauses the script’s execution until a key is pressed, when the script terminates as there are no more commands. In Windows, if the script is run within a Command Prompt window, the window remains open at the prompt as in MS-DOS, otherwise the command prompt windows closes on termination (unless the batch file has a command to prevent this).

Advanced window batch file example for conditional shutdown—

 

@echo off
color 0A
title Conditional Shutdown.

:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Shutdown in specified time
echo 2. Shutdown at a specified time
echo 3. Shutdown now
echo 4. Restart now
echo 5. Log off now
echo 6. Hibernate now
echo.
echo 0. Quit
echo.

set /p choice=”Enter your choice: ”
if “%choice%”==”1” goto shutdown
if “%choice%”==”2” goto shutdown-clock
if “%choice%”==”3” shutdown.exe -s -f
if “%choice%”==”4” shutdown.exe -r -f
if “%choice%”==”5” shutdown.exe -l -f
if “%choice%”==”6” shutdown.exe -h -f
if “%choice%”==”0″ exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start

:shutdown
cls
set /p min=”Minutes until shutdown: ”
set /a sec=60*%min%
shutdown.exe -s -f -t %sec%
echo Shutdown initiated at %time%
echo.
goto cancel

:shutdown-clock
echo.
echo the time format is HH:MM:SS (24 hour time)
echo example: 14:30:00 for 2:30 PM
echo.
set /p tmg=enter the time that you wish the computer to shutdown on:
schtasks.exe /create /sc ONCE /tn shutdown /st %tmg% /tr “shutdown.exe -s -t 00″
echo shutdown initiated at %tmg%
echo.

:cancel
set /p cancel=”Type cancel to stop shutdown: ”
if not “%cancel%”==”cancel” exit
shutdown.exe -a
cls
schtasks.exe /end /tn shutdown
cls
schtasks.exe /delete /tn shutdown
cls
echo Shutdown is cancelled.
echo.
pause
exit

 

Save this as anoop.bat in notepad.Now open this file you will find like this—
welcome username
What would you like to do?
1. shutdown in specific time
2. shutdown at a specific time
3. shutdown now
4. Restart now
5. Log off now
6. Hibernate now

0. quit
enter your choice

Now chose your choice & press enter and get the result.
I think it contains enjoyable content. Now please rate this and like this on facebook.


One comment on “Batch File

  1. Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword….wait there’s even more Now what if i told you there was a simple WordPress plugin that does all the On-Page SEO, and automatically for you? That’s right AUTOMATICALLY, just watch this 4minute video for more information at. Seo Plugin

Leave a comment