如何仅获取“程序和功能"中的那些软件列表?控制面板? [英] How to get only those software list which are in "Programs and Features" control panel?

查看:38
本文介绍了如何仅获取“程序和功能"中的那些软件列表?控制面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 VBS 代码:

This is my VBS code:

Const HKEY_LOCAL_MACHINE = &H80000002
Dim strComputer, strKeyPath
Dim objReg, strSubkey, arrSubkeys
Dim Name, Version

strComputer = "."

' Registry key path of Control panel items for installed programs
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

'Enumerate registry keys.
For Each strSubkey In arrSubkeys
    objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & strSubkey, "DisplayName" , Name
    If Name <> "" Then
         WScript.Echo Name&""&","
    End If
Next

WScript.Echo "Installed Programs listed successfully through Registry using VBScript."
WScript.Quit

它将给出所有软件名称列表.但我只想要那些在控制面板的程序和功能中可见的软件.

It will give all software name list. But I want only those software which are visible in Programs and Features in the Control Panel.

推荐答案

您可以将 shell 与 KNOWNFOLDERID 程序和功能.

You can use shell with KNOWNFOLDERID of Programs and Features.

这会为您提供您在控制面板上看到的确切列表.

This gives you the exact list you see on the control panel.

Set Shell = CreateObject("Shell.Application")
Set Programs = Shell.NameSpace("shell:::{7b81be6a-ce2b-4676-a29e-eb907a5126c5}")
For Each item In Programs.Items
    WScript.Echo item
Next

这篇关于如何仅获取“程序和功能"中的那些软件列表?控制面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆