如何获取Windows上已安装的软件列表?

本文最后更新于2019年6月28日,已超过 1 年没有更新,如果文章内容失效,还请反馈给我,谢谢!

如何获取Windows上已安装的软件列表?
搜索关键字:
注意事项:

需要循环遍历以下3个注册表键值才可能取得全(否则经常会有漏记的):

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

简单示例:

PowerShell

Get-WmiObject -Class Win32_Product | Select-Object -Property Name > D:\PCapps.txt

WMIC

/output:D:\InstallList.txt product get name,version
示例2:
Dim objNetwork, objReg
Dim HOSTNAME, USERNAME
Dim OS_ARCH

'初始化对象
Set objNetwork = CreateObject("WScript.Network")
if Err <> 0 or Not IsObject(objNetwork) then
    DisplayCustomError "CreateObject WScript.Network failed"
    Wscript.Quit
end if

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
if Err <> 0 or Not IsObject(objReg) then
    DisplayCustomError "CreateObject StdRegProv failed"
    Wscript.Quit
end if

'获取主机名/用户名
HOSTNAME = objNetwork.ComputerName
USERNAME = objNetwork.UserName

OS_ARCH = func_get_os_type()
Function func_get_os_type()
    Dim ObjectWMI, colItems, objItem, X86orX64

    Set ObjectWMI = GetObject("winmgmts:\\.\root\cimv2")
    if Err <> 0 or Not IsObject(ObjectWMI) then
        DisplayCustomError "GetObject \root\cimv2 failed"
        exit function
    end if

    Set colItems = ObjectWMI.ExecQuery("Select * from Win32_ComputerSystem",,48)
    if Err <> 0 or Not IsObject(colItems) then
        DisplayCustomError "Query Win32_ComputerSystem failed"
        exit function
    end if

    For Each objItem in colItems
        If InStr(objItem.SystemType, "86") <> 0 Then
            X86orX64 = "x86"
        ElseIf InStr(objItem.SystemType, "64") <> 0 Then
            X86orX64 = "x64"
        Else
            X86orX64 = objItem.SystemType
        End If
    Next

    func_get_os_type = X86orX64

    Set colItems = Nothing
    Set ObjectWMI = Nothing
End Function

Dim subkey, Result
Dim subkey1, subkey2
Dim SystemManufacturer, SystemProductName, SystemFamily, SystemVersion
Dim BuildLab, BuildLabEx, CSDBuildNumber, CSDVersion, CurrentBuildNumber, CurrentVersion, EditionID, InstallationType, InstallDate, ProductName

'获取硬件信息
subkey1 = "SYSTEM\CurrentControlSet\Control\SystemInformation"
subkey2 = "HARDWARE\DESCRIPTION\System\BIOS"
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey1, "SystemManufacturer", SystemManufacturer
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey1, "SystemProductName", SystemProductName
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey2, "SystemFamily", SystemFamily
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey2, "SystemVersion", SystemVersion

'获取操作系统信息
subkey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "BuildLab", BuildLab
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "BuildLabEx", BuildLabEx
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "CSDBuildNumber", CSDBuildNumber
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "CSDVersion", CSDVersion
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "CurrentBuildNumber", CurrentBuildNumber
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "CurrentVersion", CurrentVersion
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "EditionID", EditionID
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "InstallationType", InstallationType
objReg.GetDWORDValue  HKEY_LOCAL_MACHINE, subkey, "InstallDate", InstallDate
objReg.GetStringValue HKEY_LOCAL_MACHINE, subkey, "ProductName", ProductName
参考链接:
使用VBScript进行文件读写操作
示例:
'将数据写入文件
function func_write_to_file(filename, data)
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.CreateTextFile(filename, True)  #注意是CreateTextFile而不是OpenTextFile
    f.Write data
    f.Close
End function

'调用方法
func_write_to_file "result.txt", "this is a test string"
func_write_to_file "result.txt", "this is a test string" & vbCrLf

 

声明: 除非注明,ixyzero.com文章均为原创,转载请以链接形式标明本文地址,谢谢!
https://ixyzero.com/blog/archives/1952.html

5 thoughts on “如何获取Windows上已安装的软件列表?”

  1. windows NT的意义和各个版本
    https://blog.csdn.net/flyingpig2016/article/details/53282895/

    Windows NT是什么? Windows NT内核是什么?版本号对应操作系统介绍
    http://www.winwin7.com/JC/Win7JC-6960.html
    `
    版本格式:开始日期-服务结束日期

    Microsoft Windows NT 3.1 (1993-2000) 7年
    Microsoft Windows NT 3.5 (1994-1995) 1年
    Microsoft Windows NT 3.51 (1995-2001) 6年
    Microsoft Windows NT 4.0 (1996-2007) 11年
    Microsoft Windows 2000 (Windows NT 5.0) (1999) (2000-2010) 10年
    Microsoft Windows XP (Windows NT 5.1) (2001-2014.4.8) 13年
    Microsoft Windows Server 2003 (Windows NT 5.2) (2003-2015) 12年
    Microsoft Windows Server 2003 R2 (Windows NT 5.2) (2006-2015) 9年
    Microsoft Windows Vista (Windows NT 6.0) (2006-2017) 11年
    Microsoft Windows Server 2008 (Windows NT 6.0) (2008-2018) 10年
    Microsoft Windows 7 (Windows NT 6.1) (2009-2020) 11年
    Microsoft Windows Server 2008 R2 (Windows NT 6.1) (2009-2018) 9年
    Microsoft Windows 8.0 (Windows NT 6.2) (2012-2016) 4年
    Microsoft Windows Server 2012(Windows NT 6.2) (2012-2023) 11年
    Microsoft Windows Phone 8 (Windows NT 6.2) (2012-2014) 2年
    Microsoft Windows 8.1 (未安装更新的)(Windows NT 6.3) (2013-2014) 1年
    Microsoft Windows 8.1 (已安装更新的)(Windows NT 6.3) (2013-2023)10年
    Microsoft Windows Server 2012 R2 (Windows NT 6.3) (2013-2023) 11年
    Microsort Windows 10【Windows NT 10.0】【2015至2025年】
    `

a-z进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注