Alternative to BAT vs. CMD

In Reader to Reader: "BAT vs. CMD" (July 2001, InstantDoc ID 21110), Chris Taylor recommends naming batch files with a .bat or .cmd extension depending on whether the files will run in Windows 9x (.bat) or Windows 2000 or Windows NT (.cmd). You can also use the .cmd extension for Windows XP. I prefer to use the following code in my batch files to determine the underlying OS and branch to the appropriate sections of code:

If "%OS%" 

"Windows_NT" goto winnt If NOT "%WINBOOTDIR%"

"" goto win95

If you use this method, remember to make :winnt and :win95 portions in your script. Also, you need to create an :end portion and use the Goto command to send both sections there. Otherwise, you might run both sections on one of the two platforms.

Hide 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.