Complete List of BAT File Commands
Basic Commands
echo - Displays messages or turns command echoing on/off
@echo off - Hides the commands as they are executed
rem - Adds a comment
pause - Pauses the batch file and waits for user input
cls - Clears the screen
exit - Exits the script or command prompt
File and Directory Management
dir - Lists files and directories
cd / chdir - Changes the current directory
md / mkdir - Creates a new directory
rd / rmdir - Removes a directory
del - Deletes a file
copy - Copies files from one location to another
xcopy - Extended copy command for files and folders
move - Moves files from one folder to another
ren / rename - Renames a file or folder
Logic and Flow Control
if - Conditional logic (e.g., if A==B)
if exist - Checks if a file or folder exists
goto - Jumps to a labeled section
:label - Creates a label to jump to
call - Calls another batch file or function
choice - Prompts user for a choice
setlocal / endlocal - Controls variable scope
Complete List of BAT File Commands
Looping
for - Loops over a set of values or files
Example: - for %%i in (*.txt) do echo %%i
Variables
set - Creates or modifies variables
set /p - Prompts the user to input a value
set /a - Performs arithmetic operations
System Information & Control
systeminfo - Displays system configuration
tasklist - Lists running processes
taskkill - Ends tasks by name or PID
shutdown - Shuts down or restarts the system
time / date - Displays or sets the system time/date
Networking
ipconfig - Shows IP configuration
ping - Tests network connection
netstat - Shows network stats
tracert - Traces route to a host
net - Manages users, shares, network connections
User and Admin Commands
net user - Manage user accounts
Complete List of BAT File Commands
runas - Run a command as another user
whoami - Shows the current user
attrib - Changes file attributes (read-only, hidden, etc.)
Example: Sample BAT File
@echo off
echo Welcome to my Batch File
set /p name=Enter your name:
echo Hello, %name%!
pause