batch file, determine which os

Status
Not open for further replies.

office politics

It's all just 1s and 0s
Messages
6,555
Location
in the lab
I want to create a batch file that will determine which OS is running on the pc and run commands specifically for that OS.

I really only need for it to distinguish between 98 & 2k OSs. I was thinking that I would try to detect the folder 'documents and settings'. I tried to use the following line of code on an xp pc but it would produce the expected results.

@echo off
if exist "C:\documents and settings\nul" echo docs and settings exists
 
How would you like the results displayed? On the screen or a txt file?

If you were to have the results displayed on the screen, try something like this.

On Screen
================================================

@echo on

winver

rem winver will tell windows to display the current OS version along with build and SP information. A window is activated showing you a graphical interface


================================================


If you want to have the results saved to a file try this.

Off Screen
================================================

@echo off

ver > version.txt

rem ver will tell the script to display the current OS version , > tells the script to send the results to the "version.txt" file (it will create this in the root directory by default) this is a variable so you can change the name of the file name or location if you'd like.




================================================
 
Status
Not open for further replies.
Back
Top Bottom