Ticker

6/recent/ticker-posts

How to create basic batch file Beginners | Batch programming

How to create basic batch or .bat file?


Batch File is a script file. A batch file (also known as a .bat file or batch script) is a text file that is executed as a batch job by the Windows cmd.exe command line processor. It consists of a plain text file containing a set of commands to be performed by the command-line interpreter.
A batch file is a computer program or script that contains data or tasks that are series wise processed by Command.



How to create basic batch file for beginners | Batch programming script



Following are the steps for creating a basic batch file on Windows 10:

Step 1: Open Notepad by searching for it in the start menu.

Step 2: To create your very first batch file, type the batch code, one example is shown below:


Creating basic batch file very easily beginners. Batch file commands batch script batch programming bat coding xxcopy examples batch file Create .bat



@ECHO OFF ECHO Congratulations! You have created your very first batch file.
PAUSED


The above script outputs the following line, 
"Congratulations! You have created your very first batch file."

Step 3: Click the File menu.

Step 4: Select the option of 'save as'.

Step 5: Type a name, for example, file_name.bat.

Note that the extension for batch files is . bat

Step 6: Now, run the saved file to see your outputs.


Terms related to Batch programming, coding and scripts


Now, we will look out for some of the terms which we had used in our script that what actually they do so that you can create your own Batch (.bat) file any time.

■ @ECHO OFF: When echo is turned off, the command prompt doesn't appear in the window, it means the prompt window hides so that a cleaner view is seen as the output. Usually, this line goes at the beginning of the file. 

"@," this symbol hides the command being executed for creating more clean output.

We can also avoid this symbol, there wouldn't be much effect on the output.

■ ECHO: ECHO is used to show any text on the output screen.

■ PAUSE: It prevents the window from being closed on its own after the command has been executed. The window remains opened if we use it. We generally use this at the end of scripts.

Please note that while batch files use the .bat file extensions, you can also see some scripts with .cmd or .btm as file extensions.


■ % AND %% SIGN: Percent sign ( % ) is used to carry out for command at the command prompt while double percent signs ( %% ) to carry out the for command within a batch file.

Post a Comment

0 Comments

Recent Posts