Skip to main content

Installed Software List on Remote Machine using Registry

Public Sub SoftwareInformationRegistry(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String)

        Dim objLocator, objService, objRegistry, arrIdentityCode, strIdentityCode, objShell
        Dim objFSO, objTextFile
        Dim strRegIdentityCodes As String

        objLocator = CreateObject("WbemScripting.SWbemLocator")


        Try

            If (strComputer = System.Environment.MachineName) Then

                objService = objLocator.ConnectServer(strComputer, "Root\Default")
            Else
                objService = objLocator.ConnectServer(strComputer, "Root\Default", strUserName, strPwd)
            End If

            objService.Security_.impersonationlevel = 3

            objRegistry = objService.Get("StdRegProv")

        Catch ex As Exception

            MessageBox.Show("Kindly Enter Domain Credential.", "Remote Software Install", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Exit Sub

        End Try


        strRegIdentityCodes = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"


        Const HKLM = &H80000002
        Const APPEND = 8

        Dim strRegIdentityInfo, strDisplayName, strDisplayVersion, strInstallDate, strUninstallString, strPublisher

        objRegistry.EnumKey(HKLM, strRegIdentityCodes, arrIdentityCode)
        objShell = CreateObject("WScript.Shell")

        Dim strName As String

        objFSO = CreateObject("Scripting.FileSystemObject")
        objTextFile = objFSO.CreateTextFile("c:\software.txt", True)
        objTextFile.WriteLine("Name" & vbTab & _
                        "Version" & vbTab & "Install Date" & vbTab & _
                        "UninstallString" & vbTab & "Publisher")

        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")

                strName = strDisplayName

                If (strName.StartsWith("Hotfix") Or strName.StartsWith("Security") Or strName.StartsWith("Update")) Then

                Else

                    objTextFile.WriteLine(strDisplayName & vbTab & strDisplayVersion & vbTab & strInstallDate & vbTab & strUninstallString & vbTab & strPublisher)

                End If

                strDisplayName = ""
                strDisplayVersion = ""
                strInstallDate = ""
                strUninstallString = ""
                strPublisher = ""

            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

Popular posts from this blog

Ping Network Computer in VB.Net

"Ping" is very basic utility for every network programmer. Here we will discuss ping a computer in Network using VB.Net. We have two methods for pinging a computer. Method 1: Here we will use VB.Net NetworkInformation NameSpace. Public Sub PingStatus(ByVal strComputer As String) Dim pingSender As Ping = New Ping() Dim options As PingOptions = New PingOptions() options.DontFragment = True 'Create a buffer of 32 bytes of data to be transmitted Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Dim buffer As Byte() = Encoding.ASCII.GetBytes(data) Dim timeout As Integer = 120 Dim reply As PingReply = pingSender.Send(strComputer, timeout, buffer, options) If (reply.Status = IPStatus.Success) Then MessageBox.Show("Ping Successed.") Else MessageBox.Show("Ping Faild.") End If End Sub Method 2: Here we are using .Net inbuil

GridView Paging and Sorting

Introduction Paging and Sorting are most commonly used features of ASP.Net GridView. And it is very easy to implement in GridView with small lines of code. Here I am going to demonstrate how to use Paging and Sorting in GridView for better use of data display.