.CMD

CMD File

Windows NT Command Script
Ask a question
QUICK ANSWER

A CMD file is a plain-text Windows command script that runs automatically when you double-click it. To read what it does without running it, right-click and choose Edit - this opens it in Notepad. Never double-click a CMD file from an untrusted source; it executes immediately and is a common malware delivery format.

Developer: Microsoft Category: Executable Files MIME: application/x-cmd
OPENS ON Windows macOS Linux
Related: .APK · .EXE · .VBS · .JAR

On this page

19k+ extensions indexed
Last reviewed Jun 22, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the CMD file format?

A .cmd file is a plain-text Windows NT command script executed by cmd.exe, the Windows Command Prompt interpreter. It is nearly identical to the older .BAT batch file format, with one important behavioral difference: a .cmd file always runs with command extensions enabled, giving access to enhanced IF/FOR syntax, CALL :label sub-routines, %~nx0 path expansions, and reliable ERRORLEVEL handling - without requiring registry configuration.

Introduced in 1993 with Windows NT 3.1 alongside the new cmd.exe interpreter, the .cmd extension was Microsoft's way to distinguish NT-native scripts from legacy DOS .bat files, which ran under COMMAND.COM. Both extensions remain fully supported through Windows 11.

A .cmd script consists of sequential cmd.exe commands, labels (:name), flow-control keywords (GOTO, CALL, IF, FOR), and variable expansions (%VAR%). SETLOCAL/ENDLOCAL blocks isolate environment-variable changes to the script's scope. There are no magic bytes - the file is plain text, typically saved in ANSI/Windows-1252 encoding; UTF-8 works but a byte-order mark (BOM) at the start can break the first command line.

.cmd files are executable: double-clicking one runs all commands immediately. Always inspect an untrusted .cmd file in a text editor before running it. For modern Windows automation, PowerShell scripts (.ps1) are preferred, though .cmd remains essential for legacy systems and lightweight task automation.

Security & safety

RISK: HIGH

A .cmd file is EXECUTABLE: double-clicking it runs every command immediately with your user privileges. It can delete or encrypt files, change system settings, download additional malware, disable security tools, or exfiltrate data. It is a standard malware delivery format, often disguised as a "fix", "installer", "optimizer" or "activation crack", and is commonly sent as an email attachment or downloaded from fake support pages. SAFE HANDLING: never double-click an untrusted .cmd file. To inspect it, right-click > Show more options > Edit (opens in Notepad without executing). Look for these red flags: commands that call powershell/curl/bitsadmin/certutil to download files, base64-encoded strings, attempts to disable Windows Defender or UAC, writes to AppData/system folders, or long obfuscated strings of caret (^) escapes. If in doubt, upload the file to VirusTotal (it is a text file, safe to upload) and run it only inside a VM/sandbox. Note: .cmd files from well-known software (Gradle, Maven, Node.js wrappers) are safe but should still come from their official distributions, not third-party downloads.

Format details

in a nutshell
FULL NAMEWindows NT Command Scriptaka CMD script, Windows command file
DEVELOPERMicrosoftsince 1993 with Windows NT 3.1 / OS/2 as the NT-era sibling of the DOS .bat extension
MIME TYPEapplication/x-cmd
TYPEPlain-text script of Command Prompt (cmd.exe) commands executed sequentially

Programs that open CMD files

Windows5 apps
PSPad Free Programmer's editor with batch syntax highlighting - opens and inspects .cmd for editing.
Notepad Open-source Open the .cmd in Notepad++ for syntax-highlighted inspection and editing before running.
Notepad (to INSPECT - do not double-click) Built-in Right-click the .cmd file > Show more options > Edit - opens in Notepad so you can READ the commands without executing them.
Visual Studio Code Free Open the .cmd as text in VS Code; batch syntax highlighting makes obfuscated or malicious lines easier to spot.
Command Prompt (cmd.exe) - to RUN Built-in Only when trusted: open a Command Prompt, type the full path to the .cmd file. Running from a prompt keeps the window open so you see output and errors.
macOS2 apps
Parallels Desktop Paid Run a Windows VM on Mac, then execute the .cmd inside that Windows environment.
Any text editor (VS Code, TextEdit) Free macOS can only READ a .cmd file as plain text - it cannot execute Windows cmd.exe commands. Open to inspect; run on Windows (or inside a Windows VM).
Linux1 app
Any text editor (VS Code, gedit, nano) Free Linux reads .cmd as text only; cmd.exe batch syntax is not natively executable. Inspect here, run on Windows (Wine's cmd handles simple scripts imperfectly).

Technical details

deep spec
EncodingText - typically ANSI/Windows-1252 or ASCII; UTF-8 is supported but a BOM at the start can break the first command
ContainerPlain text
EncryptionNone (plain text; no built-in code-signing unlike PowerShell .ps1 scripts)
Typical size100 bytes - 100 KB
StructureSequential cmd.exe commands, labels (:name), IF/FOR/GOTO/CALL flow control, %VAR% expansions, SETLOCAL/ENDLOCAL blocks
Command extensionsAlways enabled in .cmd files (unlike .bat, which depends on the EnableExtensions registry setting)
Interpretercmd.exe (not the legacy COMMAND.COM used for DOS .bat files)
Magic bytesNone - plain text; many files begin with @echo off, REM, or :: (comment line)
Associated OSWindows NT 3.1 and all later versions, including Windows 11
Superseded byPowerShell (.ps1) for modern automation; .cmd and .bat remain fully supported as of Windows 11
Execution behaviorDouble-clicking runs all commands immediately; always inspect in a text editor before running untrusted files
Released1993 with Windows NT 3.1 / OS/2 as the NT-era sibling of the DOS .bat extension
Latest versionNo versioned spec; behavior defined by the cmd.exe of each Windows release (Windows 11 as of 2026)
Specificationlearn.microsoft.com

CMD conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with CMD files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about CMD files.

Frequently asked questions

Is it safe to open a .cmd file?
Opening it in a text editor to READ is safe - nothing executes. Double-clicking RUNS the commands, which is dangerous for files you didn't write or don't trust. Always right-click > Edit first.
What is the difference between .cmd and .bat?
They are almost identical Windows command scripts. .cmd is the Windows NT version (since 1993) with command extensions always enabled; .bat is older (since MS-DOS 1981). Most scripts run the same either way. Use .cmd when your script needs reliable command extensions.
How do I run a .cmd file?
Double-click it, or open a Command Prompt window and type the file path. Running it from a Command Prompt keeps the window open so you can read the output and errors.
How do I edit a .cmd file without running it?
Right-click the file in Explorer, choose Show more options, then Edit - it opens in Notepad. Alternatively, drag it into Notepad++, VS Code, or any text editor.
How do I convert a .cmd file to an .exe?
Use a wrapper like the free Bat To Exe Converter or Windows' built-in IExpress. This bundles the script into a self-extracting EXE without compiling it; antivirus may flag the result as suspicious.
Why does a .cmd file appear in every software installation folder?
Many tools (Node.js, Gradle, Maven, Yarn, etc.) ship a .cmd launcher on Windows so you can run them from the Command Prompt by name. These are safe wrapper scripts included by the developer.
Can a .cmd file run on Mac or Linux?
No - .cmd uses Windows cmd.exe syntax. You can read it as text on any OS, but to execute it you need Windows (or a Windows VM/emulator).

References

1Microsoft Learn - cmd.exe documentationlearn.microsoft.com
2Microsoft Learn - Windows commands referencelearn.microsoft.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.MDMarkdown Document
3.CRDOWNLOADChrome Partial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.PARTPartial Download File
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.ICSiCalendar data file

Related extensions

.APKAndroid Package
.EXEWindows Executable (Portable Executable)
.VBSVBScript file (Visual Basic Script)
.JARJava Archive
.EX4MetaTrader 4 Compiled Program (Expert Advisor / Indicator / Script)
.APPXMicrosoft Windows App Package (AppX)

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z