You are currently offline, waiting for your internet to reconnect

Command Prompt (Cmd.exe) Runs Files That Do Not Have Executable File Name Extensions

Support for Windows XP has ended

Microsoft ended support for Windows XP on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article has been archived. It is offered "as is" and will no longer be updated.
When you use a command prompt (Cmd.exe, or the Windows command processor) to open a file that does not have an executable file name extension, the file may run as a program instead of being opened in the program that is registered for the file type (based on the file name extension).

For example, if you type filename or filename.txt at a command prompt, Filename.txt may run as a program instead of being opened in Notepad. This may also occur if the file is called as a command line in a batch (.bat) file or in a Windows NT command script (.cmd) file.
This issue may occur if the following conditions exist:
  • The file is a binary image that contains an executable header. For example, the file is a .com or .exe file that has been renamed with a different file name extension.
  • You do not specify a program for Cmd.exe to use to open the file.
When you type a file name at a command prompt, or you use a file name as a command line in a batch file or Windows NT command script, Cmd.exe calls the CreateProcess function to open the file. The CreateProcess function examines the file's contents. If the file's binary image contains an executable header (which indicates that the file is really a .com or .exe file), the file is run as a program. This behavior is compatible with previous versions of Windows NT.
Open the file by using Windows Explorer, or use the following command line to open the file in the appropriate program:
program filename.ext
For example, to open Filename.txt in Notepad, use the following command line:
notepad filename.txt
Some files contain viruses or can otherwise damage your computer. If you are not confident that a file is safe, take precautions such as these before you open the file:
  1. Check the file with a virus scanner.
  2. Save your work and quit other programs.
  3. Disconnect from the Internet or from any other network connections.
Cmd.exe recognizes files with .com, .exe, .bat, .cmd, .vbs, .js, and .ws extensions, and any other extensions that are defined by the PATHEXT environment variable as executable files, but it can also run files without these known extensions if the file's binary image contains an executable header.

Windows and Microsoft Internet Explorer perform additional checks before opening a file. This includes determining if any program is associated with the file name extension in the registry. This MIME-type detection permits Windows Explorer and Internet Explorer to find and start the object server or program that is associated with the file name extension.
For additional information about computer viruses, click the following article number to view the article in the Microsoft Knowledge Base:
129972 Description of Computer Viruses
For additional information about MIME-type detection, visit the following Microsoft Web site: For additional information about the CreateProcess function, visit the following Microsoft Web site:
datasniffing worm trojan horse infected infection

Article ID: 811528 - Last Review: 12/08/2015 01:48:46 - Revision: 5.0

Microsoft Windows XP Home Edition, Microsoft Windows XP Professional, Microsoft Windows XP Media Center Edition 2005 Update Rollup 2, Microsoft Windows XP Tablet PC Edition, Microsoft Windows XP Professional x64 Edition, Microsoft Windows 2000 Server, Microsoft Windows 2000 Professional Edition, Microsoft Windows 2000 Advanced Server, Microsoft Windows NT Server 4.0 Standard Edition, Microsoft Windows NT Workstation 4.0 Developer Edition

  • kbnosurvey kbarchive kbprb KB811528