简体   繁体   中英

How to determine Windows version from a batch script for an inactive drive?

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.

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"

我认为一个相当强大的方法是查看标准操作系统文件的文件版本元数据,例如%SystemRoot%\\ system32 \\ winver.exe。

I did the following (from command prompt): 'findstr /i "filever.sion" 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 ile V e r sion 6. 1. 7 6 0 1. 1 9 1 3 5 ( win 7 sp 1 _ gd 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM