简体   繁体   English

VBScript列出Windows Server 2008 R2上已安装的软件

[英]VBScript list installed softwares on windows server 2008 R2

I want to list the installed softwares on windows server 2008 R2 with a VBscript. 我想用VBscript列出Windows Server 2008 R2上的已安装软件。 I want to verify prerequisite softwares (one of them is .NET Framework 3.5.1). 我想验证必备软件(其中之一是.NET Framework 3.5.1)。 I actually have two solutions and they both doesn't show all the softwares. 我实际上有两个解决方案,但它们都没有显示所有软件。

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
installedSoftwaresPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

Set objReg = GetObject("winmgmts://./root/default:StdRegProv")

objReg.EnumKey HKLM, installedSoftwaresPath, arrSubkeys
For Each strSubkey In arrSubkeys
    Ret = objReg.GetStringValue(HKLM, installedSoftwaresPath & strSubkey, "DisplayName", SoftwareName)
    If Ret <> 0 Then
    objReg.GetStringValue HKLM, strKey & strSubkey, "QuietDisplayName", SoftwareName       
    End If
    If SoftwareName<> "" Then
        WScript.Echo VbCrLf & "Display Name: " & SoftwareName
    End If
Next

The other solution is this one : 另一个解决方案是:

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product")

For Each objSoftware in colSoftware
    WScript.Echo objSoftware.Caption
Next

Is it possible to get ALL the installed softwares? 是否可以获得所有已安装的软件? if not I'm gonna make a specific solution for every prerequisite softwares. 如果没有,我将为每种必备软件提供特定的解决方案。

EDIT : Some software found by my scripts : 编辑:我的脚本找到了一些软件:

Microsoft Application Error Reporting, Microsoft Visual C++ 2008 Redistributable, Microsoft Security Client, Adobe Reader Microsoft应用程序错误报告,Microsoft Visual C ++ 2008可再发行组件,Microsoft安全客户端,Adobe Reader

What I want to found : .NET framework 3.5.1 我想找到的是.NET Framework 3.5.1

I want a generic solution to found every softwares installed. 我想要一个通用的解决方案来找到所有已安装的软件。

SOLUTION : It seems that there is no generic way to check for installed software. 解决方案:似乎没有通用的方法来检查已安装的软件。 I've found the .NET framework registry key in this path : 我在以下路径中找到了.NET Framework注册表项:

"SOFTWARE\Microsoft\MSBuild\ToolsVersion\v3.5\"

Without having access to your server to see how the software you're looking for is installed, I can only guess at how you might modify your script. 在无法访问服务器以查看所需软件的安装方式的情况下,我只能猜测您将如何修改脚本。

However, there are other places you should probably be looking besides: HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ 但是,除了其他地方,您可能还应该查找其他地方:HKLM \\ SOFTWARE \\ Microsoft \\ Windows \\ CurrentVersion \\ Uninstall \\

For example, you may want to look in: 例如,您可能需要查看:

HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
HKLM\SOFTWARE\Classes\Installer
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData

It's possible that you will find what you are looking for in one of those locations. 您可能会在这些位置之一中找到所需的内容。

You may also want to use RegEdit to do a "Find" for ".NET Framework 3.5.1" to see if that shows up somewhere that you can reliably find it. 您可能还需要使用注册表编辑器做一个“查找”为” .NET框架3.5.1" ,看看是否在某个地方显示出来,你可以可靠地找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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