Reputation: 12369
How can one get the version of Windows from the shell (command prompt) via a batch script for a drive that does not contain the active OS? I was hoping for some file that I could test, but it turns out things are a little more vague than I'd hoped. This should be able to determine the version of Windows for all NT releases from 2000 to 8.1.
Upvotes: 0
Views: 389
Reputation: 9
I did the following (from command prompt): 'findstr /i "f.i.l.e.v.e.r.s.i.o.n" kernel32.dll > ver' The dots are required because the metadata is unicode, and findstr will thus ignore the zeros that are between the letters (dot being a wildcard for "any single character"). (see: findstr /?). The snippet can be examined in notepad or, on some systems that still support "EDIT", "EDIT /70 VER". The output is still unicode, but it can be "prettied up" using programming (f/e vbscript). the raw material can be examined "as is": F i l e V e r s i o n 6 . 1 . 7 6 0 1 . 1 9 1 3 5 ( w i n 7 s p 1 _ g d r . 1 6 0 1 2 1 - 1 7 1 8 ) 2. Googling windows versions yielded: me=4.9, 2000=5.0, xp=5.1, vista=6.0, 7=6.1, 8=6.2, 8.1=6.3, 10=10.0, (then a bunch more while microsoft put out fires, then 11=21H2. (7601 is the "build" number") Above taken from: https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
Upvotes: -1
Reputation: 24535
I would think a fairly robust method would be to look at the file version metadata for a standard OS file such as %SystemRoot%\system32\winver.exe.
Upvotes: 1
Reputation: 917
you can load the windows registry from the "inactive OS' Drive" and read the version from it:
this is not tested, but it's something like this:
set SYSTEM_DRIVE=D:
reg load "HKU\ttt" "%SYSTEM_DRIVE%\Windows\System32\config\SOFTWARE"
reg query "HKU\ttt\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName
reg unload "HKU\ttt"
Upvotes: 1