Kaseya Community

Get Add/Remove Programs Script

  • This script was taken out of the old k forum. it contains 2 parts, the script, and a vbs file.

    here is the vbs:

    '*****************
    '* Inventory.vbs *
    '*****************
    
    Set objShell = CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    Set objWMIService = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    Set objSpoolerService = objWMIService.Get("Win32_Service.Name='Spooler'")
    strRegIdentityCodes = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    strRegComputerName = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
    strComputerName = objShell.RegRead(strRegComputerName)
    Const HKLM = &H80000002
    Const APPEND = 8
    strFileOut = strComputerName & "_addremovelist.txt"
    If objFSO.FileExists(strFileOut) Then
    Set objFileOut = objFSO.OpenTextFile(strFileOut, APPEND)
    objFileOut.WriteLine("")
    Else
    Set objFileOut = objFSO.CreateTextFile(strFileOut)
    End If
    objFileOut.WriteLine("Inventory for " & strComputerName & " at " & Now)
    objFileOut.WriteLine("Computer Name" & vbTab & "Identity Code" & vbTab & "Display Name" & vbTab & _
    "Display Version" & vbTab & "Install Date" & vbTab & "Uninstall String" & vbTab & _
    "Quiet Uninstall String")
    objReg.EnumKey HKLM, strRegIdentityCodes, arrIdentityCode
    On Error Resume Next
    For Each strIdentityCode in arrIdentityCode
    strRegIdentityInfo = "HKLM\" & strRegIdentityCodes & "\" & strIdentityCode & "\"
    strDisplayName = objShell.RegRead(strRegIdentityInfo & "DisplayName")
    strDisplayVersion = objShell.RegRead(strRegIdentityInfo & "DisplayVersion")
    strInstallDate = objShell.RegRead(strRegIdentityInfo & "InstallDate")
    strUninstallString = objShell.RegRead(strRegIdentityInfo & "UninstallString")
    strQuietUninstallString = objShell.RegRead(strRegIdentityInfo & "QuietUninstallString")
    objFileOut.WriteLine(strComputerName & vbTab & strIdentityCode & vbTab & strDisplayName & vbTab & _
    strDisplayVersion & vbTab & strInstallDate & vbTab & strUninstallString & vbTab & _
    strQuietUninstallString)
    strDisplayName = ""
    strDisplayVersion =""
    strInstallDate = ""
    strUninstallString = ""
    strQuietUninstallString = ""
    Next
    objFileOut.Close
  • Here is the script:

    Script Name: Get Add Remove Program List
    Script Description: This Script will collect the add/remove program list including Install Dates, and uninstall strings and put them in a tab delimated file.

    This script uses Inventory.vbs.

    IF True
    THEN
       Get Variable
         Parameter 1 : 10
         Parameter 2 :
         Parameter 3 : atemp
             OS Type : 0
       Write File
         Parameter 1 : #atemp#\Inventory.vbs
         Parameter 2 : VSASharedFiles\VBS\Inventory.vbs
             OS Type : 0
       Execute File
         Parameter 1 : %WINDIR%\System32\cscript.exe
         Parameter 2 : #atemp#\Inventory.vbs
         Parameter 3 : 3
             OS Type : 0
       Get File
         Parameter 1 : %WINDIR%\System32\%COMPUTERNAME%_addremovelist.txt
         Parameter 2 : InstalledApps.txt
         Parameter 3 : 1
             OS Type : 0
    ELSE

     



    [edited by: myArch-man at 2:16 PM (GMT -7) on 10-18-2010] post is script without spaces.
  • This is AWESOME Thanks myArch-man

  • Set WshShell = WScript.CreateObject("Wscript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colSoftware = objWMIService.ExecQuery ("SELECT * FROM Win32_Product")

    se("java")
    se("adobe reader")

    Sub se(strMatchPtrn)
        For Each objSoftware in colSoftware
            strPhrase = objSoftware.Name
            Set re = New RegExp
            re.Pattern = strMatchPtrn
            re.IgnoreCase = True
            re.Global = True
            Set Matches = re.Execute(strPhrase)
            If Matches.Count <> 0 Then 
                WScript.Echo objSoftware.Name
            End If
        Next
    End Sub

  • here's what I've gotten so far, I wanted to set this to auto check add/remove at agent install. my thought is to check for AV, remove it and add my own AV, install adobe reader, java, etc.....

    I can get the sub to run and echo the reg's I'm looking for, but wanted it parse to a var to kick off an action for install as well :( I'm going to pick over your VBS to put something working together for this. I see your's dumps to a file... nice

    I'll post whenever I'm done (if i can get it to work anyways), incase anyone else wants it.

    My thought is automated agent on-boardings (used in non-domain environments so can't use GPO's)

  • Just a thought too danrche, but Audit in Kaseya has the uninstall strings and the program names installed on each computer, which would be stored in Kaseya.  To save part of the script you may be able to refer to that to see if the programs you want / don't want are there.  

  • That's Audit > View individual data > Machine Summary > Software > Add/Remove.

    There would have to be a way of referencing this in the database