windows - Get the major version number of OS using command prompt -



windows - Get the major version number of OS using command prompt -

i checking os version using command prompt.

i using next code version number

systeminfo | findstr /b /c:"os version" output for windows server 2003 os version: 5.2.3790 service pack 2 build 3790 for windows 7 os version: 6.1.7601 service pack 1 build 7601

but not sure how can have major version number (first digit of version)

how can major version number or

if can check if version numbers first char 5 or 6

you pipe output 1 time again through findstr, example:

systeminfo | findstr /b /c:"os version" | findstr /c:" 6."

and check errorlevel returned see if 6. nowadays in returned string.

note:

i've set space @ origin of sec string seek , ensure doesn't match against else might stuffed output systeminfo on "os version" line this brittle relies on format of returned text systeminfo there's doubtless improve way ver command for robust way of doing independent of format of text returned systeminfo/ver, consider writing little programme in c# (express edition free) looks @ system.environment.osversion property , sets error level string parse-free (and lot less break)!

windows command-line

Comments

Popular posts from this blog

javascript - I need to update the text of a paragraph by inline edit -

javascript - THREE.js reposition vertices for RingGeometry -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -