How to Get a List of All Built-in Commands in Batch Script
The Windows command prompt has a rich set of internal commands: these are the core building blocks of any batch script, such as IF, SET, FOR, and ECHO. Unlike external commands (like ping.exe or ipconfig.exe), these commands are built directly into the command processor (cmd.exe) itself and do not exist as separate files on the disk. For both beginners learning the language and experts needing a quick reference, there is a simple, built-in command to list them all: HELP.
This guide will teach you how to use the HELP command to display a list of all available internal commands and their functions. You will also learn how to get detailed syntax for any specific command and how to save this information to a file to create your own command reference.
The Core Command: HELP
The HELP command is a simple utility with one primary purpose: to provide information about the internal commands available in cmd.exe.
The syntax:
- To list all commands:
HELP - To get help for a specific command:
HELP <CommandName>
Basic Example: Displaying the Command List
Running the HELP command with no arguments is the quickest way to see what's available.
@ECHO OFF
ECHO --- Displaying a list of all built-in commands ---
ECHO.
HELP
The output is a formatted, alphabetized list of commands with a brief, one-line description of what each one does.
For more information on a specific command, type HELP command-name
ASSOC Displays or modifies file extension associations.
BREAK Sets or clears extended CTRL+C checking.
CALL Calls one batch program from another.
CD Displays the name of or changes the current directory.
CHCP Displays or sets the active code page number.
...
TITLE Sets the window title for a command prompt window.
TYPE Displays the contents of a text file.
VER Displays the Windows version.
VERIFY Tells Windows whether to verify that your files are written
correctly to a disk.
VOL Displays a disk volume label and serial number.
... (and many more) ...
How to Get Detailed Help for a Specific Command
The main HELP list provides only a brief summary. To get the full syntax and all available options for a specific command, you use HELP followed by the command's name.
@ECHO OFF
ECHO --- Getting detailed help for the 'IF' command ---
ECHO.
HELP IF
Alternatively, most external commands and many internal ones support the /? switch, which does the same thing.
IF /?
Saving the Command List to a File
The list of commands is long. For easier reference, you can save it to a text file using the output redirection operator (>).
@ECHO OFF
SET "OutputFile=%USERPROFILE%\Desktop\Batch_Command_List.txt"
ECHO --- Saving a list of all commands to a file ---
ECHO Output will be saved to: "%OutputFile%"
HELP > "%OutputFile%"
ECHO.
ECHO [SUCCESS] List saved.
What HELP Shows You (Internal vs. External Commands)
It is crucial to understand that HELP only lists internal commands.
- Internal Commands: These are part of
cmd.exeitself. Examples includeSET,IF,FOR,ECHO,GOTO,CALL,DIR,DEL,COPY,MD,RD, andREM. They are always available. - External Commands: These are separate executable files (
.exe,.com,.bat) located somewhere on the disk (usually inC:\Windows\System32). Examples includePING.EXE,IPCONFIG.EXE,CHKDSK.EXE,TASKLIST.EXE,SHUTDOWN.EXE, andFINDSTR.EXE. TheHELPcommand will not list these. To get help for an external command, you must use the/?switch (e.g.,ping /?).
Common Pitfalls and How to Solve Them
The HELP command is very simple and has few pitfalls. The main point of confusion is simply understanding the difference between internal and external commands and knowing that HELP is the tool for the former, while /? is the tool for the latter.
Practical Example: A "Command Reference Generator" Script
This advanced script creates a comprehensive reference file. It first gets the list of all command names from HELP, and then it loops through that list, running HELP <command> for each one and appending the detailed output to a single, large text file.
@ECHO OFF
SETLOCAL
SET "ReferenceFile=%USERPROFILE%\Desktop\Full_Command_Reference.txt"
ECHO --- Generating Full Command Reference ---
ECHO Saving to: "%ReferenceFile%"
ECHO This may take a moment...
(
ECHO Windows Batch Command Reference
ECHO Generated on %DATE% at %TIME%
) > "%ReferenceFile%"
REM --- The core logic ---
REM 'skip=1' ignores the header line of the HELP command.
FOR /F "skip=1 tokens=1" %%C IN ('HELP') DO (
(
ECHO.
ECHO ==========================================================
ECHO HELP FOR: %%C
ECHO ==========================================================
ECHO.
HELP %%C
) >> "%ReferenceFile%"
)
ECHO.
ECHO [SUCCESS] Reference file created.
START "" "%ReferenceFile%"
ENDLOCAL
Conclusion
The HELP command is the essential, built-in tool for exploring the capabilities of the Windows command prompt and for getting quick reminders of a command's syntax.
Key takeaways:
- Run
HELPwith no arguments to get a complete list of all internal commands. - Run
HELP <CommandName>to get detailed syntax and options for a specific internal command. - For external commands (like
ping.exe), you must use the/?switch instead (e.g.,ping /?). - Redirect the output with
> filename.txtto save the information for later reference.