Windows Command Enumerator: Technical Documentation
1. Overview
Windows Command Enumerator is a specialized C utility designed for the Windows operating system that systematically scans and lists all available command-line tools accessible to the user. It distinguishes between Internal Commands (built into cmd.exe) and External Commands (executable files located in the system directory). This tool is particularly useful for system administrators, developers, and security researchers who need a comprehensive inventory of available system utilities without relying on external scripts or manual lookup.
The application leverages native Win32 API functions to ensure accurate detection of system files and provides a color-coded, formatted output for improved readability in the console.
2. Compilation and Installation
Prerequisites
- Operating System: Windows (XP, 7, 8, 10, 11, or Server editions).
- Compiler: MinGW-w64 (GCC) or Microsoft Visual Studio (MSVC).
- Libraries: Standard Windows libraries (
kernel32.lib,user32.lib, etc., linked automatically by most compilers).
Build Instructions
Using MinGW (GCC)
gcc -o cmd_enumerator.exe main.c
Using Microsoft Visual Studio (Developer Command Prompt)
cl main.c /Fe:cmd_enumerator.exe
3. Usage
The program is a standalone executable with no command-line arguments. Simply run it in a Command Prompt (cmd.exe) or PowerShell window.
./cmd_enumerator.exe
Output Structure
The output is divided into two main sections:
Internal Windows Shell Commands:
- Listed manually from a hardcoded array within the source code.
- These are commands like
dir,copy,echo, andcdwhich are not separate.exefiles but are interpreted directly by the shell. - Displayed in Cyan.
External System Commands:
- Discovered dynamically by scanning the
%SystemRoot%\System32directory. - Includes all
.exeand.comfiles found in this directory. - Displayed in White/Gray.
- Discovered dynamically by scanning the
At the end of the scan, the total count for each category is displayed, followed by usage hints in Yellow.
4. Technical Implementation Details
4.1. Internal Command Enumeration
Since internal commands do not exist as physical files on the disk, they cannot be detected via file system APIs. The program uses a static constant array INTERNAL_COMMANDS containing approximately 60 standard CMD built-ins.
const char* INTERNAL_COMMANDS[] = {
"ASSOC ", "ATTRIB ", "BREAK ", ... "XCOPY ", "WMIC "
};
4.2. External Command Enumeration (Win32 API)
The core functionality relies on the Windows File Search API to scan the system directory.
Retrieve System Directory: The function
GetSystemDirectory()is used to safely obtain the path toSystem32(e.g.,C:\Windows\System32), ensuring compatibility across different Windows installations where the drive letter or folder name might vary.File Search Pattern: The program constructs a search pattern
C:\Windows\System32\*.exeand usesFindFirstFile()andFindNextFile()to iterate through all matching entries.Filtering and Formatting:
- Directory Filtering: The
dwFileAttributesfield is checked againstFILE_ATTRIBUTE_DIRECTORYto skip subfolders. - Extension Removal: The
.exeor.comextension is stripped from the filename usingstrrchr()to present a clean command name (e.g.,ipconfig.exebecomesipconfig).
- Directory Filtering: The
Secondary Scan for .COM Files: A second pass is performed for
*.comfiles to capture legacy executables that might still be present in the system directory.
4.3. Console Formatting
- Color Handling: The
SetColor()function usesGetStdHandle(STD_OUTPUT_HANDLE)andSetConsoleTextAttribute()to change text colors dynamically.- Cyan (11): Internal Commands header.
- Green (10): External Commands header.
- Gray (8): Descriptive text.
- White (7): Command lists.
- Yellow (14): Footer/Help text.
- Column Layout: The output is formatted into columns (5 columns for internal commands, 3 for external) using
printfwidth specifiers (e.g.,%-15s) to ensure alignment.
5. Error Handling
- System Directory Retrieval: If
GetSystemDirectory()fails, the program prints an error message and aborts the external scan. - File Search Failure: If
FindFirstFile()returnsINVALID_HANDLE_VALUE, an error is reported, preventing crashes during iteration. - Buffer Overflows: Fixed-size buffers (
MAX_PATH) are used for paths, which is standard for Windows API interactions.
6. Limitations and Considerations
Scope of Scan:
- The tool only scans
%SystemRoot%\System32. It does not scan:-
%SystemRoot%\SysWOW64(on 64-bit systems). - Directories listed in the user's
PATHenvironment variable (e.g.,C:\Program Files\Git\bin). - User-installed applications.
-
- Note: To see commands from other directories, users should rely on the system
PATHvariable, but this tool specifically targets core OS utilities.
- The tool only scans
Internal Command List:
- The list of internal commands is hardcoded. If new internal commands are added in future Windows updates, they will not appear unless the source code is updated and recompiled.
Permissions:
- Running this tool does not require Administrator privileges, as reading the
System32directory is allowed for standard users. However, some listed commands may require elevation to execute successfully.
- Running this tool does not require Administrator privileges, as reading the
Performance:
- Scanning
System32involves reading thousands of file entries. While fast on modern SSDs, it may take a few seconds on older hardware.
- Scanning
7. Example Output
========================================================
WINDOWS ALL-COMMANDS ENUMERATOR v2.0
========================================================
Scanning system for available commands...
=== [1] INTERNAL WINDOWS SHELL COMMANDS (Built-in) ===
ASSOC ATTRIB BREAK BCDEDIT CACLS
CALL CD CHCP CHDIR CHKDSK
...
Total Internal Commands: 64
=== [2] EXTERNAL SYSTEM COMMANDS (Scanning C:\Windows\System32) ===
(These are executable tools found in your Windows System32 folder)
arp attrib audiodg
authz bcdboot bcdedit
...
Total External Commands Found: 1250
========================================================
DONE. You can use any of these commands in CMD/Powershell.
To execute a command, simply type its name.
To get help for a specific command, type: <COMMAND > /?
========================================================
Press Enter to exit...
8. Security Note
This tool is read-only and does not modify system files. However, listing all available executables can be useful for reconnaissance in penetration testing scenarios. Ensure you have authorization before using this tool on systems you do not own.

Log in or sign up for Devpost to join the conversation.