中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-13 07:24
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS学习入门 & 精彩文章 (教学室) » Question for the experts: can a batch file get Windows version information?
Printable Version  1,515 / 8
Floor1 zww3008 Posted 2004-01-16 00:00
初级用户 Posts 21 Credits 197
I often make various batch programs to use on different machines, and sometimes I need to perform different operations for different systems. So how can I use a batch file to get Windows version information (and make it general-purpose)?
In Windows I use the installer creation program CreatInstall 2000 to define macros and get values from the registry, and that works, but I don't know whether this can be done in a batch file.
Floor2 Wengier Posted 2004-01-16 00:00
系统支持 Posts 10,521 Credits 27,736
Under DOS? Try the WINVER command.
Floor3 zww3008 Posted 2004-01-18 00:00
初级用户 Posts 21 Credits 197
winver is a 32-bit program. It seems to exist only in Windows 98 (C:\WINDOWS\WINVER.EXE); I didn't find it in XP. So there goes the idea of general compatibility. More importantly, it only pops up a window and can't export the information for a batch file to use.
Floor4 Wengier Posted 2004-01-18 00:00
系统支持 Posts 10,521 Credits 27,736
zww3008: if you run WINVER under pure DOS, it won't pop up a window, but will display the Windows version number, for example: Windows 98
Floor5 willsort Posted 2004-01-26 00:00
元老会员 Posts 1,512 Credits 4,432
Floor6 zww3008 Posted 2004-02-03 00:00
初级用户 Posts 21 Credits 197
Heh~ just got back after the New Year!
What brother willsort introduced in post #5 are all ways to get DOS version information. What I need is a way to run a batch file in Windows and get WINDOWS version information such as windows 98/Me/2000/XP, etc. I wonder if there is any workable method?
Floor7 willsort Posted 2004-02-04 00:00
元老会员 Posts 1,512 Credits 4,432
Re zww3008:

After actual testing, both under WIN 98 and WIN XP what I got was the WINDOWS version value, which is why I recommended it to you.
Floor8 zww3008 Posted 2004-02-04 00:00
初级用户 Posts 21 Credits 197
It really works, that's amazing! I often like to DIY little programs, and being able to obtain this kind of information is quite useful to me!
::getvar.bat
@if == prompt set %2=%3
@if == goto end
@echo off
%comspec% /c %0 invoke %1 %2>tt.bat
call tt

:end
But there are still some things I don't quite understand, please explain in detail:
1. What is prompt in the second line? Does it mean the %prompt% variable? If so, why isn't it enclosed in double % signs? And are it and the following set two commands written on one line? In win98 can two commands be written directly on one line? Where does %3 get its value from?
2. When using it, the command line is getvar curver $v. Do curver and $v correspond respectively to invoke and %1 in “%comspec% /c %0 invoke %1 %2”? Then what does %2 correspond to?
3. The question I'm asking you involves parameter issues with command /c and the like, which I've run into many times, but the help from command /? isn't very detailed, and I haven't found relevant materials either. Could you give a detailed and comprehensive introduction to the parameters of command?
Floor9 willsort Posted 2004-02-06 00:00
元老会员 Posts 1,512 Credits 4,432
Re zww3008:

1. prompt is used here as an internal command, and set is merely its string-form parameter. After being output to tt, its content becomes set curver=current version, so set becomes an internal command and is called;

2. In Windows, two commands can be used on one line, but there are certain limitations, and it is not suitable for the needs here.
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=12&ID=9106

3. The parameter correspondence is as follows:
::getvar.bat
This line is followed by execution of @if == prompt set %2=%3 here %1 is invoke, %2 is curver, and %3 is the system's current version
@if == goto end
@echo off
This line first executes %comspec% /c %0 invoke %1 %2>tt.bat here %1 is curver, %2 is $v, and invoke is the marker word for calling the subroutine
call tt

4. For detailed usage of command, you can refer to the DOS help document I uploaded. The link is as follows:
http://model.chinajewelry.net/dos/dosbbs/dispbbs.asp?boardID=12&ID=9266
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023