Jump to content

how to query all installed programs on remote computer


Recommended Posts

thanks. but when i execute the code, it does not give me anything or list of all programs currently installed

RegEnumVal("\\hpsrvcunit\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", 1)

If @error Then MsgBox(0, "Warning", "Program not installed")

Link to comment
Share on other sites

  • Moderators

thanks. but when i execute the code, it does not give me anything or list of all programs currently installed

RegEnumVal("\\hpsrvcunit\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", 1)

If @error Then MsgBox(0, "Warning", "Program not installed")

He's showing you how to enum through the values... you'd have to place that in a loop, and where "1" is, would be the current loop number you are on.

Something like:

#include <array.au3>
Local $s_computer = "hpsrvcunit"
Local $i_next, $s_val, $v_delim = Chr(1)

While Not @error
    $i_next += 1
    $s_val = RegEnumVal("\\" & $s_computer & "\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i_next)
    $s_hold &= $s_val & $v_delim
WEnd

Local $a_list = StringSplit(StringRegExpReplace($s_hold, "[\" & $v_delim & "]+\z", ""), $v_delim, 1)
_ArrayDisplay($a_list)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This script will give you an array with all the software installed in the local or remote pc.

#include <Array.au3>

$ret = _SoftwareInfo()
_ArrayDisplay($ret, '')

Func _SoftwareInfo($s_RemoteComputer = '')
    Local $Count = 1
        
    If $s_RemoteComputer <> '' Then $s_RemoteComputer = '\\' & StringReplace($s_RemoteComputer, '\', '') & '\'      
    Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    
    While 1
        $key = RegEnumKey ($regkey, $Count)
        If @error <> 0 then ExitLoop
        $line = RegRead ($regkey & '\' & $key, 'Displayname')
        $line = StringReplace ($line, ' (remove only)', '')

        If $line <> '' Then
            If Not IsDeclared('avArray') Then Dim $avArray[1]
            ReDim $avArray[UBound($avArray) + 1]
            $avArray[UBound($avArray) - 1] = $line          
        EndIf
        $Count = $Count + 1
    WEnd

    If Not IsDeclared('avArray') Or Not IsArray($avArray) Then
        Return(SetError(1, 0, ''))     
    Else
        $avArray[0] = UBound($avArray) - 1
        Return(SetError(0,0, $avArray))
    EndIf
EndFunc

This other one I use when I want to install an application. This is script won't work remote, but it will give you an array with the software names and version. You can pass the application name and if is installed it will give you the name and version. Ex: _SoftwareList('microsoft .net framework 1.1') if .Net 1.1 is installed it will return the info otherwise return an array value 0 meaning is not installed and you can run your script to install the application.

#include <Array.au3>

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$List = _SoftwareList()
_ArrayDisplay($List)

$List = _SoftwareList('microsoft .net framework 1.1')
_ArrayDisplay($List)

Func _SoftwareList($sSoftwareName = '')
    Dim $aSoftwareList[1][2]
    $objInstaller = ObjCreate('WindowsInstaller.Installer')

    $Products = $objInstaller.Products
    For $Product In $Products
        If $sSoftwareName <> '' And $sSoftwareName <> $objInstaller.ProductInfo($Product, 'ProductName') Then ContinueLoop
        ReDim $aSoftwareList[UBound($aSoftwareList) + 1][2]
        $aSoftwareList[UBound($aSoftwareList) - 1][0] = $objInstaller.ProductInfo($Product, 'ProductName')
        $aSoftwareList[UBound($aSoftwareList) - 1][1] = $objInstaller.ProductInfo($Product, 'VersionString')
    Next
    $aSoftwareList[0][0] = UBound($aSoftwareList) - 1
    Return ($aSoftwareList)
EndFunc  ;==>_SoftwareList

Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    ConsoleWrite("We intercepted a COM Error !" & @CRLF & _
            "Number is: " & $HexNumber & @CRLF & _
            "Windescription is: " & $oMyError.windescription)

    SetError(1); something to check for when this function returns
EndFunc  ;==>MyErrFunc
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

  • Moderators

Eeek... I put Val and Not "Key" ... noticed that with Danny's code.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

hi. i've manage to put an inputbox on your script so that i can select to which computer i want to query all the installed software. but how will i query for a specific program only. Let say i wanted to query if WinZIP or Adobe Acrobat is installed or not on the computer.

here is the code:

#include <Array.au3>

#include <GUIConstantsEx.au3>

Local $strComputer, $strInput

Do

$strComputer = (InputBox("List software","Enter COMPUTER NAME to query list of installed programs."))

If $strComputer <> '' Then

$strInput = 1

EndIf

Until $strInput = 1

$return = _SoftwareInfo()

_ArrayDisplay($return, "Installed Programs")

Func _SoftwareInfo($computer = $strComputer)

Local $Count = 1

If $computer <> '' Then $computer = '\\' & StringReplace($computer, '\', '') & '\'

Local Const $regkey = $computer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'

While 1

$key = RegEnumKey ($regkey, $Count)

If @error <> 0 then ExitLoop

$line = RegRead ($regkey & '\' & $key, 'Displayname')

$line = StringReplace ($line, ' (remove only)', '')

If $line <> '' Then

If Not IsDeclared('avArray') Then Dim $avArray[1]

ReDim $avArray[uBound($avArray) + 1]

$avArray[uBound($avArray) - 1] = $line

EndIf

$Count = $Count + 1

WEnd

If Not IsDeclared('avArray') Or Not IsArray($avArray) Then

Return(SetError(1, 0, ''))

Else

$avArray[0] = UBound($avArray) - 1

Return(SetError(0,0, $avArray))

EndIf

EndFunc

Link to comment
Share on other sites

JohnRichard

Try this:

#include <Array.au3> ;Only for array displaying

Local $strComputer, $strInput

$strComputer = (InputBox("List software","Enter COMPUTER NAME to query list of installed programs."))

If $strComputer = '' Then
    $strComputer = "\\" & @ComputerName & "\" ;current computer
Else
    $strComputer = "\\" & $strComputer & "\"
EndIf

$return = _SoftwareInfo($strComputer)
_ArrayDisplay($return, "Installed Programs")

Func _SoftwareInfo($computer = $strComputer)
    Local Const $regkey = $computer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    Local $key, $Count = 0, $avArray[1]
    
    While 1
        $Count = $Count + 1
        $key = RegEnumKey($regkey, $Count)
        If @error Then ExitLoop
        
        $line = RegRead($regkey & '\' & $key, 'Displayname')
        If @error Then ContinueLoop
        
        $line = StringReplace($line, ' (remove only)', '')

        $avArray[0] += 1
        ReDim $avArray[$avArray[0] + 1]
        $avArray[$avArray[0]] = $line 
    WEnd
    
Return $avArray
EndFunc
Link to comment
Share on other sites

  • 2 years later...

Hi John:

Thank you for this script I'm been using it for a while now. Just a couple thing that I would like to know. Did you find a way of been able to exit the script without actually entering a computer name. The close "X" does not work. Also did you find the way of just looking for one software. Any chances of been able to sort the result?

Thanks.

hi. i've manage to put an inputbox on your script so that i can select to which computer i want to query all the installed software. but how will i query for a specific program only. Let say i wanted to query if WinZIP or Adobe Acrobat is installed or not on the computer.

here is the code:

#include <Array.au3>

#include <GUIConstantsEx.au3>

Local $strComputer, $strInput

Do

$strComputer = (InputBox("List software","Enter COMPUTER NAME to query list of installed programs."))

If $strComputer <> '' Then

$strInput = 1

EndIf

Until $strInput = 1

$return = _SoftwareInfo()

_ArrayDisplay($return, "Installed Programs")

Func _SoftwareInfo($computer = $strComputer)

Local $Count = 1

If $computer <> '' Then $computer = '\\' & StringReplace($computer, '\', '') & '\'

Local Const $regkey = $computer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'

While 1

$key = RegEnumKey ($regkey, $Count)

If @error <> 0 then ExitLoop

$line = RegRead ($regkey & '\' & $key, 'Displayname')

$line = StringReplace ($line, ' (remove only)', '')

If $line <> '' Then

If Not IsDeclared('avArray') Then Dim $avArray[1]

ReDim $avArray[uBound($avArray) + 1]

$avArray[uBound($avArray) - 1] = $line

EndIf

$Count = $Count + 1

WEnd

If Not IsDeclared('avArray') Or Not IsArray($avArray) Then

Return(SetError(1, 0, ''))

Else

$avArray[0] = UBound($avArray) - 1

Return(SetError(0,0, $avArray))

EndIf

EndFunc

Link to comment
Share on other sites

I have been playing with the script made two adjustment

1) right click now give the option to run the uninstall string (rather than just copy to clipboard)

2) input box to return only software with that string in the DisplayName (so 'Adobe' = adobe air, adobe acrobat, adobe CS.....)

3) Leaving the default of 'ALL' returns all software

*edit 4) If you cancel the inputbox the program exits

#include <GuiListView.au3>
Opt("TrayAutoPause", 0)
Opt('GUIOnEventMode', 1)
;
Global $i
Local $sSft
Global $sGui = GUICreate(' Installed Software Viewer v1.0.0', 810, 650, -1, -1)
Global $sLvw = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600)
_ComputerGetSoftware($sSft)



For $i = 1 To ubound($sSft) - 1
    GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $sLvw)
Next
GUICtrlSendMsg($sLvw, 0x101E, 1, 175)
GUICtrlSendMsg($sLvw, 0x101E, 2, 65)
GUICtrlSendMsg($sLvw, 0x101E, 3, 150)
GUICtrlSendMsg($sLvw, 0x101E, 4, 350)
Local $mMen = GUICtrlCreateContextMenu($sLvw)
;~ Local $CopI = GUICtrlCreateMenuItem('Copy Uninstall String to Clipboard', $mMen)
Local $CopI = GUICtrlCreateMenuItem('Uninstall Current Selection', $mMen)
;~ GUICtrlSetOnEvent($CopI, '_Copy2Clip')
GUICtrlSetOnEvent($CopI, '_Uninstall')
Local $exp = GUICtrlCreateButton('  Expand  ', 720, 615)
GUICtrlSetOnEvent($exp, '_Expand')
GUISetOnEvent(-3, '_AllExit')
GUISetState(@SW_SHOW, $sGui)

While 1
    Sleep(10)
WEnd
;
Func _AllExit()
    GUIDelete($sGui)
    Exit
EndFunc
;
Func _Uninstall()
    Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1)
    If $proc[1] == 0 Then Return -1
    If $proc[5] Then ShellExecuteWait ($proc[5])
        exit
EndFunc
;
Func _Copy2Clip()
    Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1)
    If $proc[1] == 0 Then Return -1
    If $proc[5] Then ClipPut($proc[5])
EndFunc
;
; Author JSThePatriot - Modified June 20, 2010 by ripdad
Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
    Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1
    Dim $aSoftwareInfo[1][4]
    $input = inputbox ("Which Software" , "Which Software?", 'ALL')
    If @Error = 1 Then Exit
    If $input = 'ALL' Then
    For $j = 1 To 500
        $AppKey = RegEnumKey($UnInstKey, $j)
        If @error <> 0 Then Exitloop
        If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
        ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
        $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
        $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
        $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
        $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
        $i = $i + 1
    
    Next
    $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
    If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)        
    Return _ArraySort($aSoftwareInfo)
    
Else
        
    For $j = 1 To 500
        $AppKey = RegEnumKey($UnInstKey, $j)
        If @error <> 0 Then Exitloop
        $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName")
        $string = stringinstr($Reg, $input)  
        If $string = 0 Then Continueloop
        ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
        $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
        $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
        $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
        $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
        $i = $i + 1
    
    Next
    $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
    If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)        
    Return _ArraySort($aSoftwareInfo)
    
    Endif
EndFunc
;
Func _Expand()
    _GUICtrlListView_SetColumnWidth($sLvw, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 2, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 3, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 4, $LVSCW_AUTOSIZE)
EndFunc
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • 10 months later...

Hi JohnRichard

I am new to AutoIT i tried your scrit to fetch the Installed Software List from Remote Computer but after running the script output is blank

have the local administrative privilege but it's not working for me i dont know what is the issue can u pls help me out i try to get list of installed software and try to set a alert and send a mail to IS team when any software intallation in procee within a Domain or LAN segment so can u eaducate me on the same cause i dont know how can i set the alert and sending mail to the particular Address, pls help me i need this.

Thanks in Advance.

Link to comment
Share on other sites

  • 1 year later...

Please don't reopen 4 year old threads. Also, your explanation is lacking all details of what you want to do and what you've done to try to accomplish this.

Open a new thread and explain in detail what it is you're trying to do and what you've tried to help you do it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...