
背景:我电脑太多了,合规提醒我某几台电脑没有按照要求安装某些管控软件
实际可能在不同硬盘上安装了多个系统,现在的需求就是离线查看某个磁盘分区里的Windows系统的计算机名
思路:通过离线查看注册表实现
用everything搜注册表,发现还有C之外2个盘符有SYSTEM注册表

reg load "HKLM\aaaaa" "d:\windows\system32\config\SYSTEM"
reg load "HKLM\bbbbb" "I:\windows\system32\config\SYSTEM"
reg query "HKEY_LOCAL_MACHINE\aaaaa\ControlSet001\Services\Tcpip\Parameters" /v hostname
reg query "HKEY_LOCAL_MACHINE\bbbbb\ControlSet001\Services\Tcpip\Parameters" /v hostname
reg unload "HKLM\aaaaa"
reg unload "HKLM\bbbbb"

顺便说下如何确认Windows系统类型,以InstallationType为准。
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v InstallationType
reg query "HKLM\SYSTEM\ControlSet001\Control\ProductOptions" /v ProductType
诸多Windows PC系统版本,“Windows Enterprise multi-session”版本,ProductType键值是ServerNT,虽然“Windows Enterprise multi-session”确实是PC系统,但如果在PC系统里读ProductType这个键值,就会被其误导做出错误判断
而离线确认操作系统版本其实读文件属性里的版本号就行,但文件太多了,具体读那些文件呢?
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\System32\kernel32.dll") |ft -auto
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\System32\KernelBase.dll") |ft -auto
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\System32\winload.exe") |ft -auto
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\System32\ntoskrnl.exe") |ft -auto
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\System32\msi.dll") |ft -auto
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Windows\explorer.exe") |ft -auto(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name LCUVer).LCUVer
cmd.exe /c ver
通过以上信息,可知,离线读取\Windows\System32\ntoskrnl.exe可确认系统版本。
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("D:\Windows\System32\ntoskrnl.exe") |ft -auto
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("I:\Windows\System32\ntoskrnl.exe") |ft -auto
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。