BAT vs. CMD

Learn to create and name batch files that Windows 2000, Windows NT, and Windows 9x will universally support.

Readers

June 12, 2001

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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.

—Chris Taylor
[email protected]

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like