Discussion Locked

Batch file to determine which NT Version

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I need to know how to figure out which version of NT a PC is using through a batch file. I know about the OS= variable but it it shows the same version if you use NT 4 or Windows 2k. Is there another variable that gives more specific info?

11 replies

by billc124

Have you tried using the VER command? It should tell you the version of Windows you are using.

by joseph moore

Ok, here you go.
This is a BAT file that will collect the IP address of the machine, the Windows version, the logged-in user name running the BAT file, and it will append all of this to a single text file. You can put this in a logon script for all of your users to use, and point it to a central share. This BAT will make a separate text file per user name. So, you will get separate files per user.
Here is the BAT file contents (call it NTVER.BAT):

@ECHO OFF
cls
ipconfig >> %username%.txt
ver >> %username%.txt
echo %username% >> %username%.txt
echo ********************* >> %username%.txt

And for me, it will make a text file called JOE.TXT that contained the following:

Windows NT IP Configuration

Ethernet adapterACC07D1:

IP Address. . . . . . . . . : 10.1.1.211

Subnet Mask . . . . . . . . : 255.255.255.0

Default Gateway . . . . . . : 10.1.1.1

Windows NT Version 4.0
JMO
*********************

I added the "****" just for fun!

Now, you can have each line of the BAT write to the same file, to append all your users into one big file. (that is why the ***** are useful)

So, either add this to an existing logon script, just run it as a BAT manually, or call it from a logon script by doing a CALL NTVER.BAT from the logon script.

Hope this helps.

by joseph moore

I forgot:
The secret to appending to the same text file is the ">>". If you did a single carat, ">" it would OVERWRITE.
But the double carat, ">>" APPENDS.

Just a little old DOS syntax.

by billc124

Just a comment. All you asked for was the variable to give you the version of NT. I gave you that. If you wanted more specific information you should have asked for it.

by faisalmasood

Joseph Moore, your script works nicely. I've used it in this way with one more option to save the computer name using HOSTNAME command.

@ECHO OFF
cls
Echo off
ipconfig >> %username%.txt
ver >> %username%.txt
hostname >> %username%.txt
echo %username% >> %username%.txt
echo The home drive is %HOMEDRIVE% >> %username%.txt
echo *************************************************** >> %username%.txt

Actually I want to use this script to track which user is logging on from which machine & which Id they are using. Actually users here are trying to access things not allowed to them using others accounts / machines.

So my only hope to track them is using this script. But this script saves the %username%.txt file in the root oof their boot partition.

Is there any way using this script to save the file on my server without giving user access to those file.

This discussion is closed to new replies.