.BAT file extension
To open .BAT files on Windows, to inspect safely, right-click the .BAT file and choose Edit, or choose Open with > Notepad.
To open a .BAT file, right-click it and choose Edit or Open with a plain-text editor such as Notepad if you want to inspect it safely. On Windows, double-clicking a .BAT file runs its commands in Command Prompt, so do not double-click unknown .BAT files.
Last updated: April 29, 2026 · Reviewed by Julian Stricker
Open on your device
Choose your operating system for a dedicated step-by-step opening guide.
How to open .BAT files
Use these platform-specific instructions to open .BAT files safely.
Windows
- To inspect safely, right-click the .BAT file and choose Edit, or choose Open with > Notepad.
- Read the commands before running the file, especially lines that delete files, download content, change system settings, or run other programs.
- To run a trusted batch file, double-click it or open Command Prompt, navigate to its folder, and type its filename.
- If the file closes too quickly, run it from an already open Command Prompt window so you can see any messages.
Mac
- .BAT files are Windows batch scripts and do not run natively on macOS.
- To view the contents, Control-click the file, choose Open With, and select a text editor.
- If you need to execute it, transfer it to a Windows system or rewrite the commands for a macOS shell script where appropriate.
Linux
- .BAT files are Windows batch scripts and do not run natively in a standard Linux shell.
- To inspect the file, open it with a text editor such as your desktop text editor or a command-line editor.
- If you need equivalent behavior, translate the commands to a shell script or run the file only in a suitable Windows-compatible environment after reviewing it.
iOS
- .BAT files cannot be run natively on iPhone or iPad.
- To view the text, open the file in Files and use Share to send it to a text editor or code editor app.
Android
- .BAT files cannot be run natively on Android.
- To view the contents, open the file with a trusted text editor app; transfer it to a Windows PC if it must be executed.
Security notes
- .BAT files can execute commands, start programs, modify files, delete data, and change system settings on Windows.
- Do not double-click a .BAT file from email, downloads, chat, or an unknown sender; inspect it with a text editor first.
- Be especially cautious of commands that use del, format, reg, powershell, curl, bitsadmin, start, or commands that download and run other files.
- Renaming a suspicious .BAT file does not make it safe; treat it as executable script content.
Recommended antivirus software
Scan files before opening them. These antivirus tools help protect against malware and viruses.
Avast offers free and premium antivirus software that protects against viruses, malware, ransomware, and phishing. Scan files before opening them to ensure safety.
NortonNorton 360 delivers comprehensive antivirus protection, VPN, and identity theft monitoring. Scan files for threats before opening to keep your device secure.
We may earn a commission when you use affiliate links. This supports our free file extension guides.
Can't open this file?
These are the most common causes and fixes when .BAT files fail to open.
Common reasons
- The .BAT file runs instead of opening for reading
- Command Prompt window opens and closes immediately
- The script does not work on macOS, Linux, iOS, or Android
- Commands fail because paths or permissions are different
Fix steps
- Right-click the file and choose Edit or Open with > Notepad instead of double-clicking.
- Review the commands before deciding whether to run it.
- Keep a backup of important files before running any batch script that changes files or settings.
OS-specific troubleshooting
What is a .BAT file?
A .BAT file is a batch file used by DOS and Microsoft Windows command interpreters. It is a plain-text script that stores one command per line or a sequence of command-shell instructions for automating tasks. Windows Command Prompt, cmd.exe, can execute .bat files, while text editors can view or modify them.
Background
.BAT is most commonly the extension for a DOS/Windows batch file, not a passive data file. Batch files are used to automate command-line tasks such as launching programs, setting environment variables, copying files, running maintenance commands, or chaining other scripts.
Common MIME types: application/x-msdos-program
Further reading
Authoritative resources for more details on the .BAT format.
Common .BAT issues
The .BAT file runs instead of opening for reading
On Windows, double-clicking a .BAT file executes it in Command Prompt, which may be unsafe for unknown files.
- Right-click the file and choose Edit or Open with > Notepad instead of double-clicking.
- Review the commands before deciding whether to run it.
- Keep a backup of important files before running any batch script that changes files or settings.
Command Prompt window opens and closes immediately
The script may finish quickly or fail before you can read the output.
- Open Command Prompt first.
- Use cd to go to the folder containing the .BAT file.
- Run the file by typing its name so the window stays open and shows messages.
The script does not work on macOS, Linux, iOS, or Android
.BAT syntax is for DOS/Windows command interpreters and is not the same as Unix shell scripting.
- Open the file in a text editor to inspect what it is trying to do.
- Run it on a trusted Windows system if it is required.
- For non-Windows systems, rewrite the commands as an appropriate shell script rather than simply renaming the file.
Commands fail because paths or permissions are different
Batch files often assume specific drive letters, folders, installed programs, or administrator permissions.
- Check the file in a text editor for hard-coded paths such as C:\ or specific program names.
- Run Command Prompt from the correct working folder.
- If the script requires elevated rights, run it only after verifying the commands and understanding the changes it will make.
FAQ
Is a .BAT file a data file?
In common use, no. A .BAT file is a Windows batch script: a plain-text file containing commands for Command Prompt.
What program opens .BAT files?
Windows Command Prompt runs .BAT files. Text editors such as Notepad can open them for viewing and editing.
Can I open a .BAT file on Mac or Linux?
You can view it as text, but it will not run natively because it uses Windows command syntax. Use Windows to run it, or translate the commands to a suitable shell script.
Can I convert a .BAT file by renaming it?
No. Renaming only changes the extension. If you need similar behavior on another system, rewrite the commands for that system's scripting language.
Similar file extensions
Compare related formats in the same category to find the right tool faster.