本文介绍了帮助从远程计算机获取已安装软件的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在已经在下面的代码上工作大约2天了,我似乎无法读取每个注册表项来向我展示安装在本地或远程座位上的所有软件.我没有收到任何错误,它将完成并显示大部分已安装的软件,但我仍然会缺少5到10个项目.如果有人可以告诉我我在做什么错,那太好了.我尝试从64位和32位位置中提取.
I have been working on the below code now for about 2 days and i cant seem to get it to read every registry key to show me all the software installed on a local seat or a remote seat. I dont get any errors and it will complete and show me a majority of the software installed but i will still be missing 5 to 10 items. If someone can please show me what i m doing wrong that would be great. I have tried pulling from both the 64 bit location and 32 bit location.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SoftwareInformationRegistry(TextBox1.Text)
End Sub
Public Sub SoftwareInformationRegistry(ByVal strComputer As String)
Dim objLocator, objService, objRegistry, arrIdentityCode, strIdentityCode, objShell
Dim strRegIdentityCodes As String
objLocator = CreateObject("WbemScripting.SWbemLocator")
Try
objService = objLocator.ConnectServer(strComputer, "Root\Default")
objRegistry = objService.Get("StdRegProv")
Catch ex As Exception
MsgBox("Unable to connect")
Exit Sub
End Try
'strRegIdentityCodes = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
strRegIdentityCodes = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
Const HKLM = &H80000002
Dim strRegIdentityInfo, strDisplayName, strDisplayVersion, strInstallDate, strUninstallString, strPublisher
objRegistry.EnumKey(HKLM, strRegIdentityCodes, arrIdentityCode)
objShell = CreateObject("WScript.Shell")
For Each strIdentityCode In arrIdentityCode
Try
strRegIdentityInfo = "HKEY_LOCAL_MACHINE\" & strRegIdentityCodes & "\" & strIdentityCode & "\"
strDisplayName = objShell.RegRead(strRegIdentityInfo & "DisplayName")
strDisplayVersion = objShell.RegRead(strRegIdentityInfo & "DisplayVersion")
strInstallDate = InstallDate(objShell.RegRead(strRegIdentityInfo & "InstallDate"))
strUninstallString = objShell.RegRead(strRegIdentityInfo & "UninstallString")
strPublisher = objShell.RegRead(strRegIdentityInfo & "Publisher")
ListView1.Items.Add(strDisplayName)
Catch ex As Exception
Continue For
End Try
Next
End Sub
Private Function InstallDate(ByVal strDate As String) As String
Try
Dim YY, MM, DD As String
YY = strDate.Substring(0, 4)
MM = strDate.Substring(4, 2)
DD = strDate.Substring(6, 2)
Return DD & "-" & MM & "-" & YY
Catch ex As Exception
End Try
End Function
推荐答案
这篇关于帮助从远程计算机获取已安装软件的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!