.BAT

BAT File

Windows Batch File
Ask a question
QUICK ANSWER

A BAT file is a plain-text Windows batch script containing Command Prompt commands that run in sequence the moment you double-click it. To read what it does first, right-click and choose Edit to open it in Notepad -- this does not execute anything. Only run a .bat file you wrote or fully trust, because it runs with your user privileges and is a common malware delivery method.

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

On this page

19k+ extensions indexed
Last reviewed Jun 25, 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 BAT file format?

.bat is the extension for DOS batch files run from the Windows command shell, cmd.exe.

Contents of .bat files

.bat files contain commands for the command shell. Batch files let users automate tasks and run multiple commands in sequence, manage applications, or control computer resources. A well-known example is AUTOEXEC.BAT, located in the root folder of the system drive on Windows 95, 98 and Me; commands in that file executed automatically at system start to launch applications and modify default settings. Today .bat files remain fully supported on all Windows versions; their close sibling, .cmd, is the Windows NT-era equivalent with command extensions enabled by default.

Can I open .bat files?

.bat files store commands in plain text and can be edited with any text editor. However, users should take care in how they open .bat files - by default, double-clicking a .bat file automatically loads it into memory and executes its commands. Right-clicking the file and selecting Edit from the context menu lets users modify the .bat file without running its instructions. For more capable scripting, PowerShell scripts (.ps1) are the modern Windows alternative.

Can a .bat file be dangerous?

Keeping in mind that commands saved in .bat files can let the system run virtually any operation, access system resources, or install software, the risk that such files can be used to install potentially dangerous software or even destabilize the machine is real. Therefore it is recommended that users not run .bat files from unknown sources. Best practices recommend that before running any .bat file users should review its contents - even files that have been on the machine for a long time. A malicious program might have modified one or more harmless .bat files in a way that running them now causes damage to the system or installs malicious software.

Security & safety

RISK: HIGH

A .bat file is EXECUTABLE: double-clicking runs every command immediately with your user privileges - it can delete files, change settings, download and launch other programs, or disable security tools. It is a common malware vector, frequently obfuscated or used as a 'dropper' that fetches a real payload, and is often disguised as a helpful 'fix', 'crack' or 'optimizer'. SAFE HANDLING: never double-click an untrusted .bat. To inspect it, right-click to Edit (or open in Notepad/Notepad++/VS Code) and READ the commands - opening in an editor does NOT execute them. Red flags inside: commands that call powershell/curl/bitsadmin to download files, base64/garbled strings, attempts to disable Defender, or writes to system folders and the registry. If unsure, upload the file to VirusTotal (it's text, so it's safe to upload) and run it only inside a VM/sandbox.

Format details

in a nutshell
FULL NAMEWindows Batch Fileaka Batch script, DOS batch file
DEVELOPERMicrosoftsince 1981 (MS-DOS 1.0; AUTOEXEC.BAT since MS-DOS / PC DOS)
MIME TYPEapplication/x-bat
TYPEPlain-text script of Command Prompt (cmd.exe) commands, executed line by line

Programs that open BAT files

Windows6 apps
Sublime Text Paid Open as text for editing with batch syntax highlighting.
PSPad Free Free programmer's editor - opens and highlights .bat for inspection/editing.
Notepad Open-source Open the file (or right-click to Edit with Notepad++) for syntax-highlighted, read-only inspection before running.
Notepad (Edit, do not run) Built-in Right-click the .bat to Show more options to Edit - opens in Notepad so you can READ the commands without executing them.
Visual Studio Code Free Open the .bat as text; batch syntax highlighting makes obfuscated/malicious lines easier to spot.
Command Prompt (cmd.exe) - to RUN Built-in Only when trusted: open cmd, type the path to the .bat and press Enter. Running from a prompt keeps the window open so you see output and errors.
macOS2 apps
Any text editor (TextEdit, VS Code) Free macOS can only READ a .bat as text - it cannot run Windows batch commands. Open it to inspect; run it on Windows (or in a Windows VM).
Parallels Desktop (to run, via Windows) Paid Runs a Windows VM on Mac; execute the .bat inside that Windows guest, not in macOS.
Linux1 app
Any text editor Free Linux reads .bat as text only; cmd.exe syntax doesn't run natively. Inspect here, run on Windows (Wine's cmd handles simple scripts imperfectly).

Technical details

deep spec
Execution enginecmd.exe (Windows Command Processor) - the shell reads and executes each line sequentially at runtime
File encodingANSI / Windows-1252 or ASCII; UTF-8 is accepted but a BOM (EF BB BF) at the very start breaks the first command
Magic bytes / signatureNone - plain text identified by the .bat extension only; most files begin with the line @echo off
Comment syntaxREM keyword (official) or :: (a double-colon label trick widely used as a single-line comment)
Variable syntax%VARIABLE_NAME% for environment variables; %1-%9 for positional parameters passed on the command line; %* for all arguments
Control flow constructsLabels (:name), GOTO, CALL (subroutines or child scripts), IF / ELSE, FOR loops, SETLOCAL / ENDLOCAL scoping
Error handlingERRORLEVEL pseudo-variable; IF ERRORLEVEL n checks; && and || conditional execution operators (requires command extensions)
Typical file size100 bytes to ~50 KB - from a few lines to a lengthy automation script
Sibling format.cmd is the Windows NT-era counterpart; command extensions are on by default, giving more reliable ERRORLEVEL and FOR /F behavior
Code signingNo native signature mechanism - unlike PowerShell .ps1 scripts, .bat files cannot be digitally signed or policy-restricted by execution policy
Security behaviour on executionDouble-clicking runs the file immediately without any preview; files downloaded from the internet receive a Mark-of-the-Web flag that triggers a SmartScreen prompt
Superseded byPowerShell (.ps1) for modern Windows automation, though .bat / .cmd remain fully supported and in widespread use
Associated platformsWindows (all versions), MS-DOS (origin), OS/2 (limited compatibility)
MIME typeapplication/x-bat (also encountered as application/bat, application/x-msdos-program, and text/plain)
Released1981 (MS-DOS 1.0; AUTOEXEC.BAT since MS-DOS / PC DOS)
Latest versionNo versioned spec; behavior tied to the cmd.exe of the Windows release (Windows 11 cmd as of 2026). .cmd is the NT-era sibling.
Specificationlearn.microsoft.com

BAT conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with BAT 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 BAT files.

Frequently asked questions

Is it safe to open a BAT file?
Opening it in a text editor to READ it is safe - that doesn't run anything. Double-clicking it RUNS the commands, which is risky for files you don't trust. Always inspect first via right-click to Edit.
How do I see what a .bat file does without running it?
Right-click the file, choose 'Show more options' then 'Edit' (or open it in Notepad++/VS Code). You'll read the commands as plain text without executing them.
How do I run a BAT file?
Double-click it, or open Command Prompt and type the full path to the file. Running it from a prompt keeps the window open so you can read its output and any errors.
How do I convert a BAT file to 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; it doesn't compile or speed it up, and antivirus may flag the result.
What's the difference between .bat and .cmd?
They're almost identical Windows batch scripts. .cmd is the newer NT version with 'command extensions' on by default; .bat keeps some DOS-era behavior. Use either - most scripts run the same.
Why does my antivirus flag a .bat file?
Because batch files can run arbitrary commands and are a common malware tool. A flag doesn't always mean infection, but inspect the contents in an editor and only run it if you trust the source.
Can a .bat file run on Mac or Linux?
No - batch files use Windows cmd.exe syntax. On Mac/Linux you can only read them; to run one you'd need Windows or a Windows VM.

References

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

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.EXEWindows Executable (Portable Executable)
6.RPMSGRestricted Permission Message
7.MDMarkdown Document
8.NOMEDIAAndroid No-Media Marker File
9.DATProgram Data File (generic)
10.TXTPlain Text 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