Excellent! Definite FAQ material. My take on that would have been
@echo off & setlocal enableextensions
for /f "tokens=3-5" %%i in (
'reg query "HKLM\software\microsoft\windows nt\currentversion" /v
csdversion ^| find "Service Pack"') do (
set pack_=%%i %%j %%k)
echo.%pack_%
endlocal & goto :EOF
The output e.g.
C:\_D\TEST>cmdfaq
Service Pack 2
P.S. Especially to the original poster: Various users have their own
preferences where to discuss different subjects. That's fine by me.
But I prefer to post my own NT/2000/XP answers to alt.msdos.batch.nt
which is meant for these platforms, so for my own posting thread I
have included and redirected. You and others will make your own free
choices as you wish just like I make mine.
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
@echo off & setlocal enableextensions
for /f "tokens=2,*" %%i in (
'reg query "HKLM\software\microsoft\windows nt\currentversion" /v
CSDVersion^
^| find "REG_SZ"') do (
set pack_=%%j)
echo.%pack_%
::
for /f "tokens=2,*" %%i in (
'reg query "HKLM\software\microsoft\windows nt\currentversion" /v
ProductName^
^| find "REG_SZ"') do (
set prod_=%%j)
echo.%prod_%
endlocal & goto :EOF
The output e.g.
C:\_D\TEST>cmdfaq
Service Pack 2
Microsoft Windows XP
> Dave R. wrote:
>> You can do something like the following:
>> [1]@echo off
>> [2]reg query "HKLM\software\microsoft\windows nt\currentversion" /v
>> csdversion | find "Service Pack 2"
>
> Excellent! Definite FAQ material. My take on that would have been
>
> @echo off & setlocal enableextensions
> for /f "tokens=3-5" %%i in (
> 'reg query "HKLM\software\microsoft\windows nt\currentversion" /v
> csdversion ^| find "Service Pack"') do (
> set pack_=%%i %%j %%k)
> echo.%pack_%
> endlocal & goto :EOF
>
> The output e.g.
> C:\_D\TEST>cmdfaq
> Service Pack 2
>
> P.S. Especially to the original poster: Various users have their own
> preferences where to discuss different subjects. That's fine by me.
> But I prefer to post my own NT/2000/XP answers to alt.msdos.batch.nt
> which is meant for these platforms, so for my own posting thread I
> have included and redirected. You and others will make your own free
> choices as you wish just like I make mine.
>
> All the best, Timo
For those of us with permission to do so, (which should really be most
people with the need to know this info), you can use the wmi commandline in
your batch file.
::-----START-----
@FOR /F "SKIP=1 DELIMS=" %%? IN ('WMIC OS GET CAPTION^,CSDVERSION') DO
@ECHO/%%?
::------END------
And for the pedants among us who noted an additional space
::-----START-----
@FOR /F "SKIP=1 DELIMS=" %%? IN ('WMIC OS GET CAPTION^,CSDVERSION') DO
(SET OSIS=%%? &CALL SET OSIS=%%OSIS: = %% &@ECHO/%OSIS%)
::------END------
Each example is a single line, therefore any line not beginning with two
spaces has wrapped.
Thank you, Timo. I'm happy to have contributed something to your FAQ.
> My take on that would have been
>
> @echo off & setlocal enableextensions
> for /f "tokens=3-5" %%i in (
> 'reg query "HKLM\software\microsoft\windows nt\currentversion" /v
> csdversion ^| find "Service Pack"') do (
> set pack_=%%i %%j %%k)
> echo.%pack_%
> endlocal & goto :EOF
>
> The output e.g.
> C:\_D\TEST>cmdfaq
> Service Pack 2
>
Nice approach - my batch skills are rusty especially when it comes to
many of the NT type enhancements.
FYI, the CurrentVersion registry key also contains values for
CurrentVersion (5.1 for XP) and ProductName (Microsoft Windows XP),
CurrentBuildNumber (2600), etc.
Best Regards,
Dave
> FYI, the CurrentVersion registry key also contains values for
> CurrentVersion (5.1 for XP) and ProductName (Microsoft Windows XP),
> CurrentBuildNumber (2600), etc.
Yes, in fact
reg query "HKLM\software\microsoft\windows nt\currentversion" /s | more
gives all kinds of interesting, and less interesting information.
Alternatively
@echo off & setlocal enableextensions
for /f "tokens=* skip=1" %%i in ('wmic OS Get CSDVersion') do (
set pack_=%%i)
echo.%pack_%
endlocal & goto :EOF
The output would be something like
C:\_D\TEST>cmdfaq
Service Pack 2
Or
@echo off & setlocal enableextensions
for /f "tokens=* skip=1" %%i in ('wmic OS Get
ServicePackMajorVersion') do (
set packMajor_=%%i)
for /f "tokens=* skip=1" %%i in ('wmic OS Get
ServicePackMinorVersion') do (
set packMinor_=%%i)
echo.%packMajor_: =%.%packMinor_: =%
endlocal & goto :EOF
The output would be something like
C:\_D\TEST>cmdfaq
2.0
>ten.n...@virgin.net wrote:
>> ::-----START-----
>> @FOR /F "SKIP=1 DELIMS=" %%? IN ('WMIC OS GET CAPTION^,CSDVERSION') DO
>> @ECHO/%%?
>> ::------END------
Just to note, WMIC is only available on XP and 2003.
Clay Calvert
CCal...@Zanguru.com
Replace "Z" with "L"
>Just to note, WMIC is only available on XP and 2003.
Since this is specifically for XP, then this one liner will also work.
systeminfo | findstr /b "OS.*Pack.2" && echo SP2 installed
> Just to note, WMIC is only available on XP and 2003.
Thank you Clay. That is very useful to know.
Thas is slightly slow. Anyway getting such gems is a good reason to
post what one has. Thank you, Clay.