15 August 2015

All Notepad Batch Commands - Ultimate Guide

Leave a Comment

All You Need To Know About Batch Programming

Most of the people think notepad is only made to save notes or texts. But few people are there who know the real power of notepad. As an in-built feature in windows, notepad can be used to make HTML ( Hyper Text Markup Language “.html” ), Batch ( “.bat” ), CPP ( “.cpp” ), JS ( Javascript “.js” ), CSS ( Cascade style sheet “.css” ), JAVA ( Java Source File ) etc Files.

In This Chapter, we only focus our mind on Batch Programming.


What Is Batch ?


Basically batch is a scripting language which works in windows, DOS and OS 2 platform and can be programmed in notepad or simply in windows Command Prompt Shell. It Consist of simple commands to be executed by command line interpreter. The file extension type of batch program is “.bat”.

Simple Example Of Batch Program


Below is the simplest code snippet for batch program which is nothing but a hello world program. After execution, this program will display “Hello world” on your computer screen.


Hello World Batch Program

@echo off

Title Hello World Program

Color 0a

Echo Hello World

Pause>nul

Exit

How To Save And Execute Batch Program


So you are newbie in batch programming and don’t know how to save and execute above program. Don’t panic, this tutorial will be your next milestone. We will introduce you with the simplest to the most hardest commands here.

Save Hello World Batch Program

To save above program, just copy it and paste inside notepad. Then click on “file>save as” and name it as “hello world.bat” or anything you want. Make sure that you had used “.bat” after file name, because it the file extension type and your program will not work without it. After that Choose File Type as “all files (*.*)” and move to the location where you want to save it. Finally when you have done, Click on the program and it will display a text as in below picture.

Note : We recommend You to use notepad++ instead of simple notepad as it is more responsive.

Some Important Batch Commands And Their Explanation


Below are all the batch or command prompt commands that will definitely help you to get some new ideas.

CommandExplanation
ASSOCDisplays or modifies file extension associations.
ATTRIBDisplays or changes file attributes.
BREAKSets or clears extended CTRL+C checking.
BCDEDITSets properties in boot database to control boot loading.
CACLSDisplays or modifies access control lists (ACLs) of files.
CALLCalls one batch program from another.
CDDisplays the name of or changes the current directory.
CHCPDisplays or sets the active code page number.
CHDIRDisplays the name of or changes the current directory.
CHKDSKChecks a disk and displays a status report.
CHKNTFSDisplays or modifies the checking of disk at boot time.
CLSChecks a disk and displays a status report.
CMDStarts a new instance of the Windows command interpreter.
COLORSets the default console foreground and background colors.
COMPCompares the contents of two files or sets of files.
COMPACTDisplays or alters the compression of files on NTFS partitions.
CONVERTConverts FAT volumes to NTFS. You cannot convert the current drive.
COPYCopies one or more files to another location.
DATEDisplays or sets the date.
DELDeletes one or more files.
DIRDisplays a list of files and subdirectories in a directory.
DISKCOMPCompares the contents of two floppy disks.
DISKCOPYCopies the contents of one floppy disk to another.
DISKPARTDisplays or configures Disk Partition properties.
DOSKEYEdits command lines, recalls Windows commands, and creates macros.
DRIVERQUERYDisplays current device driver status and properties.
ECHODisplays messages, or turns command echoing on or off.
ENDLOCALEnds localization of environment changes in a batch file.
ERASEDeletes one or more files.
EXITQuits the CMD.EXE program (command interpreter).
FCCompares two files or sets of files, and displays the differences between them.
FINDSearches for a text string in a file or files.
FINDSTRSearches for strings in files.
FORRuns a specified command for each file in a set of files.
FORMATFormats a disk for use with Windos.
FSUTILDisplays or configures the file system properties.
FTYPEDisplays or modifies file types used in file extension associations.
GOTODirects the Windows command interpreter to a labeled line in a batch program.
GPRESULTDisplays Group Policy information for machine or user.
GRAFTABLEnables Windows to display an extended character set in graphics mode.
HELPProvides Help information for Windows commands.
ICACLSDisplay, modify, backup, or restore ACLs for files and directories.
IFPerforms conditional processing in batch programs.
LABELCreates, changes, or deletes the volume label of a disk.
MDCreates a directory.
MKDIRCreates a directory.

Leave A Comment