Skip navigation

BAT vs. CMD

I work in a mixed Windows 2000, Windows NT, and Windows 9x environment. I often build batch files that work properly only under Win2K and NT because the files either call utilities that run only under those OSs or use shell functions that don't exist in Win9x. If a batch file contains portions that don't work under Win9x, running the batch file on Win9x systems can be disastrous.

To prevent problems, when I write batch files that contain no portions that will fail under Win9x, I name the file with a .bat extension, which will run under any Windows version. If I use features that only Win2K and NT support, I name the file with a .cmd extension. Win2K and NT recognize .cmd files as executable and will run them. Win9x doesn't recognize .cmd as an executable file type: If you attempt to run a file with a .cmd extension under Win9x, the OS simply reports a Bad command or file name error message, and no damage is done.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish