Alternative to BAT vs. CMD
Batch-file code to determine a system's OS.
March 24, 2002
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.
—Dave Russell
[email protected]
About the Author
You May Also Like