List all Installed Software on Remote Machine

In this article you will learn how to List all Installed Software on Local/Remote Machine.

Installed Software Information which we will gather are listed below:
Caption: Name of Software
Description: Description of the product
IdentifyingNumber: Product identification such as a serial number on software
InstallDate: Date that this product is installed on the system.
InstallLocation: Location of the installed product.
InstallState: Installed state of the product.
  • -6 = Bad Configuration
  • -2= Invalid Argument
  • -1 = Unknown Package
  • 1 = Advertised
  • 2 = Absent
  • 5 = Installed
Name: Commonly used product name.
Package Cache: The identifier for the package from which this product was installed.
SKU Number: Product SKU (stock-keeping unit) information.
Vendor: Name of the product supplier.
Version: Product version information.

Requirements:
  • Admin Credential for Remote Machine.
  • WMI Services should be started on Target Machine.
  • RPC Services should be started on Target Machine.
What are we doing here?

Here we will create FileSystemObject for writing Text File. This text file will write all Installed Software Information using Tab modifier.
strComputer = Environment.MachineName.ToString This code will check whether machine is Local or Remote. If we are using this for Remote Machine then it will use UserName and Password.
Here we are using objSWbemLocator for connecting Local or Remote Server. After this step we will use Loop for gathering Software Information.
Our last step is for closing our FileSystemObject.

List all Installed Software Source Code written in VB.Net
Public Sub SoftwareInformationVBS(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String)

        Dim objWMIService, objFSO, objTextFile, colSoftware, objSoftware, objSWbemLocator

        Try

            objFSO = CreateObject("Scripting.FileSystemObject")
            objTextFile = objFSO.CreateTextFile("c:\software.txt", True)

            objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

            If (strComputer = Environment.MachineName.ToString) Then

                objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2")
            Else
                objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strUserName, strPwd)
            End If

            objWMIService.Security_.ImpersonationLevel = 3

            colSoftware = objWMIService.ExecQuery("Select * from Win32_Product")
            objTextFile.WriteLine("Caption" & vbTab & _
                "Description" & vbTab & "Identifying Number" & vbTab & _
                "Install Date" & vbTab & "Install Location" & vbTab & _
                "Install State" & vbTab & "Name" & vbTab & _
                "Package Cache" & vbTab & "SKU Number" & vbTab & "Vendor" & vbTab _
                    & "Version")
            For Each objSoftware In colSoftware
                objTextFile.WriteLine(objSoftware.Caption & vbTab & _
                objSoftware.Description & vbTab & _
                objSoftware.IdentifyingNumber & vbTab & _
                objSoftware.InstallLocation & vbTab & _
                objSoftware.InstallState & vbTab & _
                objSoftware.Name & vbTab & _
                objSoftware.PackageCache & vbTab & _
                objSoftware.SKUNumber & vbTab & _
                objSoftware.Vendor & vbTab & _
                objSoftware.Version)
            Next
            objTextFile.Close()

        Catch ex As Exception

        End Try
        
End Sub

Related Posts by Categories



Stumble This Fav This With Technorati Add To Del.icio.us Digg This Add To Reddit Add To Facebook Add To Yahoo

1 comments:

Anonymous said...

Problem is WMI only returns msi installed software. Not everything installed.

Post a Comment