davil Registered User

Hi everyone,
Apart from writing a program in basic myself that just does a ver into a text file and checks it, is there any easy way (a command-line utility) I can determine OS version from a script? And I'm not going to be using VBS because for the time being we have multiple service packs on different machines (I know I know I'll get it sorted) and some of them will not support so I need something that should run on any 98/NT/2K/XP system without any trouble.

Anyway, this would make my life as an admin a helluva lot easier. any help appreciated.

P.S. just in case I have to go the basic route, could anybody using 98 please post the output from the VER dos command in 98? Thanks in advance.

Mr E Administrator

A bit of googling found this:

@echo off 
::parse the VER command 
FOR /F "tokens=5*" %%G IN ('ver') DO SET v_version=%%G 
:: show the result 
echo %v_version%

(It had tokens=4*, but that just returned the word 'version', so I changed it to 5 to return the number). Also, I'm not sure how to get rid of the square bracket at the end....

Return full version string with:
@echo off 
::parse the VER command 
FOR /F "tokens=*" %%G IN ('ver') DO SET v_version=%%G 
:: show the result 
echo %v_version%

Try1ng Registered User

Have you looked at Kix?

Heres a list of built in macros from kix:
KiXtart Reference

Macro Reference

Macros can be used anywhere an expression is expected. Supported macros are defined in the following table.

Bold items are new to this release

Macro Definition
@Address Address of the network adapter
@Build Build number of the operating system
@Comment User comment (Description field in User Manager)
@CPU Name of the CPU (e.g.: "Intel Pentium III")
@CRLF Returns a carriage-return line-feed combination
@CSD CSD information (eg: "Service Pack 2")
@CurDir Current directory
@Date Date (in the format YYYY/MM/DD)
@Day Day of the week (Monday, Tuesday, etc.)
@Domain Domain or workgroup the computer belongs to
@DOS Version of Windows NT
@Error Return code of the most recent command or function. A return code of 0 means the command or function was successful. Any other value indicates an error.
@FullName Full name of current user
@HomeDir Short name of the directory part of home directory
@HomeDrive* Drive letter of drive containing home directory
@HomeShr Server and share name part of home directory
@HostName Fully qualified TCP/IP host name (including TCP/IP domain name)
@InWin Operating system: 1 = Windows NT; 2 = Windows 9x
@IPaddressX TCP/IP address (possible values for X are 0 - 3).
Note: Addresses are padded so that the resulting string always consists of four sets of three characters separated by periods. For example, if your IP address is, @IPADDRESS0 is "123. 45. 6. 7"
@KiX Version of KiXtart
@LanRoot Directory where network software resides (usually Systemroot\System32)
@LDomain* Logon domain
@LDrive Drive that is redirected to \\logonserver\NETLOGON
@LM Version of network software
@LogonMode If 1, indicates that KiXtart assumes to be running during the logon sequence
@LongHomeDir Long name of the directory part of home directory
@LServer Logon server
@MaxPWAge Maximum password age (Note: if passwords are set not to expire, this value is set to ((unsigned long)-1) (or 0xFFFFFFFF in hex). This evaluates to 4294967295 decimal).
@MDayNo Day of the month (1-31)
@MHz Approximation of the CPU speed (not available on Windows 9x)
@MonthNo Month number, beginning with January (1-12)
@Month Name of the month
@MSecs Milliseconds part of the current time
@PrimaryGroup* Current user's primary group
@Priv User's privilege level (GUEST, USER, ADMIN)
@ProductSuite OS Suite. Possible Values: 1 "Small Business"
2 "Enterprise"
4 "BackOffice"
8 "CommunicationServer"
16 "Terminal Server"
32 "Small Business (Restricted)"
64 "Embedded NT"
128 "DataCenter"
256 "Single User Terminal Server"
512 "Home Edition"
1024 "Blade Server"

@ProductType OS type. Possible values:
"Windows 95"
"Windows 98"
"Windows Me"
"Windows NT Workstation"
"Windows NT Server"
"Windows NT Domain Controller"
"Windows 2000 Professional"
"Windows 2000 Server"
"Windows 2000 Domain Controller"
"Windows XP Home Edition"
"Windows XP Professional"
"Windows .Net Server"
"Windows .Net Domain Controller"
@PWAge Password age
@RAS Number of active Remote Access Service (RAS) connections
@RServer* KXRPC server used for the current session
@ScriptDir Directory of current script
@ScriptName Name of the current script
@SError Error text corresponding with @ERROR
@SID* Current user's Windows NT Security Identifier (SID)
@Site** Name of the site in which the system resides
@StartDir Directory from which KiXtart was started
@SysLang Full English name of the language of the operating system specified in the format defined by ISO Standard 639. (example : “0413Dutch (Standard)”.
@Ticks Number of milliseconds elapsed since computer was last booted.
@Time Current time (in the format HH:MM:SS)
@UserID Current user's Windows NT user ID
@UserLang Full English name of the language selected by the current user specified in the format defined by ISO Standard 639. (example : “0413Dutch (Standard)”.
@WDayNo Days since Sunday (1 – 7)
@Wksta Computer name
@WUserID Current user's Windows user ID
@YDayNo Days since January 1 (1 – 365)
@Year Current year


*Available on computers running Windows 9x only if the KiXtart RPC service is running.
**Only available on clients with full Active Directory support.

Note: During the logon sequence, @WUserID is empty on computers running Windows 9x if Windows NT Networking has been configured as the system's primary network provider.

The following examples show the correct use of KiXtart macros:



displays the file "RUUDV.TXT"

changes the current directory to "\DATA\your-domain"


davil Registered User

Thanks guys for your prompt responses. I'll look at kix now but as regards TMB's post I'm not looking for the version number, I'm looking for the Windows 2000 / Windows XP bit, but I can adapt your script to do the same. My knowledge of the if command aint amazin and I googled this myself and found sweet F.A.

Thanks again. Will report my findings.

Mr E Administrator

I modified my post to show out to output the full string.....

davil Registered User

Thanks but as I said I could modify no problem.

Try1ng Registered User

Here's an example of how i use the product type in kix:
If @PRODUCTTYPE = "Windows XP Professional"
copy "@Lserver\NETLOGON\OtherSettings\*.*" "%SystemRoot%\system32\drivers\etc"
Copy "@Lserver\NETLOGON\OtherSettings\Wireless - Out of the Office.lnk" "C:\Documents and Settings\" + @userID + "\Desktop\*.*"

davil Registered User

Ah this is good stuff lads. keep it coming.

davil Registered User

Actually, the only problem is the Windows 98 Clients need to have a couple of DLLs installed so maybe to make it simple I might do something like this:

if exist KX16.DLL copy %LOGONSERVER%\NETLOGON\kix\98c\KX16.dll %windir%\system32
if exist KX32.DLL copy %LOGONSERVER%\NETLOGON\kix\98c\KX16.dll %windir%\system32
if exist KX95.DLL copy %LOGONSERVER%\NETLOGON\kix\98c\KX16.dll %windir%\system32



IIRC find with a 0 errorlevel means that the substring is found

Ver | find "Version 4.0.950"
if not errorlevel 1 echo "Windows something"

galactus Registered User

Sorry for butting in but Bill Stewart's Windows Admin Script Tools is worth a look.

...PS I am *not* Bill Stewart...

davil Registered User


Want to share your thoughts?

Login here to discuss!