Jump to content

help with a software array


Recommended Posts

Hi there people

I need some help/advice please.
I found this script in one of the help topics. I want to adapt it to ---

Create a list that shows only the display Name and display Version of all the programs and then edit this list - add some information and remove some information - then print the final list into a text file.

To create the list I thought I'd create $Programs
Then create a function and import $Programs into it
Then after editing it I could just print the result of the function.

Thank you all.

 

#include <Date.au3> ; needed for _UninstallList function



; Examples ##########################################################################################################

#Include <Array.au3> ; Just for _ArrayDisplay
 Local $aList = _UninstallList("", "","Publisher|InstallLocation|DisplayVersion")
 _ArrayDisplay($aList, "All uninstall keys", Default, Default, Default, "RergistryPath|Key|DisplayName|InstallationDate|Publisher|InstallLocation|DisplayVersion")

; ###################################################################################################################


; #FUNCTION# ====================================================================================================================
; Name ..........: _UninstallList
; Description ...: Returns an array of matching uninstall keys from registry, with an optional filter
; Syntax ........: _UninstallList([$sValueName = ""[, $sFilter = ""[, $sCols = ""[, $iSearchMode = 0[,$ iArch = 3]]]]]])
; Parameters ....: $sValueName       - [optional] Registry value used for the filter.
;                                          Default is all keys ($sFilter do not operates).
;                  $sFilter          - [optional] String to search in $sValueName. Filter is not case sensitive.
;                  $sCols            - [optional] Additional values to retrieve. Use "|" to separate each value.
;                                          Each value adds a column in the returned array
;                  $iSearchMode      - [optional] Search mode. Default is 0.
;                                          0 : Match string from the start.
;                                          1 : Match any substring.
;                                          2 : Exact string match.
;                                          3 : $sFilter is a regular expression
;                  $iArch            - [optional] Registry keys to search in. Default is 3.
;                                          1 : x86 registry keys only
;                                          2 : x64 registry keys only
;                                          3 : both x86 and x64 registry keys
; Return values .: Returns a 2D array of registry keys and values :
;                      $array[0][0] : Number of keys
;                      $array[n][0] : Registry key path
;                      $array[n][1] : Registry subkey
;                      $array[n][2] : Display name
;                      $array[n][3] : Installation date (YYYYMMDD format)
;                      $array[n][4] : 1st additional value specified in $sCols (only if $sCols is set)
;                      $array[n][5] : 2nd additional value specified in $sCols (only if $sCols contains at least 2 entries)
;                      $array[n][x] : Nth additional value ...
; Author ........: jguinch
; ===============================================================================================================================
Func _UninstallList($sValueName = "", $sFilter = "", $sCols = "", $iSearchMode = 0, $iArch = 3)
    Local $sHKLMx86, $sHKLM64, $sHKCU = "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $aKeys[1] = [ $sHKCU ]
    Local $sDisplayName, $sSubKey, $sKeyDate, $sDate, $sValue, $iFound, $n, $aResult[1][4], $iCol
    Local $aCols[1] = [0]

    If NOT IsInt($iArch) OR $iArch < 0 OR $iArch > 3 Then Return SetError(1, 0, 0)
    If NOT IsInt($iSearchMode) OR $iSearchMode < 0 OR $iSearchMode > 3 Then Return SetError(1, 0, 0)

    $sCols = StringRegExpReplace( StringRegExpReplace($sCols, "(?i)(DisplayName|InstallDate)\|?", ""), "\|$", "")
    If $sCols <> "" Then $aCols = StringSplit($sCols, "|")

    If @OSArch = "X86" Then
        $iArch = 1
        $sHKLMx86 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Else
        If @AutoitX64 Then
            $sHKLMx86 = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
            $sHKLM64 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        Else
            $sHKLMx86 = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
            $sHKLM64 = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
        EndIf
    EndIf

    If BitAND($iArch, 1) Then
        Redim $aKeys[ UBound($aKeys) + 1]
        $aKeys [ UBound($aKeys) - 1] = $sHKLMx86
    EndIf

    If BitAND($iArch, 2) Then
        Redim $aKeys[ UBound($aKeys) + 1]
        $aKeys [ UBound($aKeys) - 1] = $sHKLM64
    EndIf


    For $i = 0 To UBound($aKeys) - 1
        $n = 1
        While 1
            $iFound = 1
            $aSubKey = _RegEnumKeyEx($aKeys[$i], $n)
            If @error Then ExitLoop

            $sSubKey = $aSubKey[0]
            $sKeyDate = StringRegExpReplace($aSubKey[1], "^(\d{4})/(\d{2})/(\d{2}).+", "$1$2$3")
            $sDisplayName = RegRead($aKeys[$i] & "\" & $sSubKey, "DisplayName")
            $sDate = RegRead($aKeys[$i] & "\" & $sSubKey, "InstallDate")
            If $sDate = "" Then $sDate = $sKeyDate

            If $sDisplayName <> "" Then
                 If $sValueName <> "" Then
                    $iFound = 0
                    $sValue = RegRead( $aKeys[$i] & "\" & $sSubKey, $sValueName)
                    If ( $iSearchMode = 0 AND StringInStr($sValue, $sFilter) = 1 ) OR _
                       ( $iSearchMode = 1 AND StringInStr($sValue, $sFilter) ) OR _
                       ( $iSearchMode = 2 AND $sValue = $sFilter ) OR _
                       ( $iSearchMode = 3 AND StringRegExp($sValue, $sFilter) ) Then
                            $iFound = 1
                    EndIf
                EndIf

                If $iFound Then
                    Redim $aResult[ UBound($aResult) + 1][ 4 + $aCols[0] ]
                    $aResult[ UBound($aResult) - 1][0] = $aKeys[$i]
                    $aResult[ UBound($aResult) - 1][1] = $sSubKey
                    $aResult[ UBound($aResult) - 1][2] = $sDisplayName
                    $aResult[ UBound($aResult) - 1][3] = $sDate

                    For $iCol = 1 To $aCols[0]
                        $aResult[ UBound($aResult) - 1][3 + $iCol] = RegRead( $aKeys[$i] & "\" & $sSubKey, $aCols[$iCol])
                    Next
                EndIf
            EndIf

            $n += 1
        WEnd
    Next

    $aResult[0][0] = UBound($aResult) - 1
    Return $aResult
EndFunc




; #FUNCTION# ====================================================================================================================
; Name ..........: _RegEnumKeyEx
; Description ...: Enumerates the subkeys of the specified open registry key. The function retrieves information about one subkey
;                  each time it is called.
; Syntax ........: _RegEnumKeyEx($sKey, $iInstance)
; Parameters ....: $sKey                - The registry key to read.
;                  $iInstance           - The 1-based key instance to retrieve.
; Return values .: Success              - A 1D array :
;                                          $aArray[0] = subkey name
;                                          $aArray[1] = time at which the enumerated subkey was last written
;                  Failure               - Returns 0 and set @eror to non-zero value
; Author ........: jguinch
; ===============================================================================================================================
Func _RegEnumKeyEx($sKey, $iInstance)
    If NOT IsDeclared("KEY_WOW64_32KEY") Then Local Const $KEY_WOW64_32KEY = 0x0200
    If NOT IsDeclared("KEY_WOW64_64KEY") Then Local Const $KEY_WOW64_64KEY = 0x0100
    If NOT IsDeclared("KEY_ENUMERATE_SUB_KEYS") Then Local Const $KEY_ENUMERATE_SUB_KEYS = 0x0008

    If NOT IsDeclared("tagFILETIME") Then Local Const $tagFILETIME = "struct;dword Lo;dword Hi;endstruct"

    Local $iSamDesired = $KEY_ENUMERATE_SUB_KEYS

    Local $iX64Key = 0, $sRootKey, $aResult[2]

    Local $sRoot = StringRegExpReplace($sKey, "\\.+", "")
    Local $sSubkey = StringRegExpReplace($sKey, "^[^\\]+\\", "")

    $sRoot = StringReplace($sRoot, "64", "")
    If @extended Then $iX64Key = 1

    If NOT IsInt($iInstance) OR $iInstance < 1 Then Return SetError(2, 0, 0)

    Switch $sRoot
        Case "HKCR", "HKEY_CLASSES_ROOT"
            $sRootKey = 0x80000000
        Case "HKLM", "HKEY_LOCAL_MACHINE"
            $sRootKey = 0x80000002
        Case "HKCU", "HKEY_CURRENT_USER"
            $sRootKey = 0x80000001
        Case "HKU", "HKEY_USERS"
            $sRootKey = 0x80000003
        Case  "HKCC", "HKEY_CURRENT_CONFIG"
            $sRootKey = 0x80000005
        Case Else
            Return SetError(1, 0, 0)
    EndSwitch

    If StringRegExp(@OSArch, "64$") Then
        If @AutoItX64 OR $iX64Key Then
            $iSamDesired = BitOR($iSamDesired, $KEY_WOW64_64KEY)
        Else
            $iSamDesired = BitOR($iSamDesired, $KEY_WOW64_32KEY)
        EndIf
    EndIf

    Local $aRetOPen = DllCall('advapi32.dll', 'long', 'RegOpenKeyExW', 'handle', $sRootKey, 'wstr', $sSubKey, 'dword', 0, 'dword', $iSamDesired, 'ulong_ptr*', 0)
    If @error Then Return SetError(@error, @extended, 0)
    If $aRetOPen[0] Then Return SetError(10, $aRetOPen[0], 0)

    Local $hKey = $aRetOPen[5]

    Local $tFILETIME = DllStructCreate($tagFILETIME)
    Local $lpftLastWriteTime = DllStructGetPtr($tFILETIME)

    Local $aRetEnum = DllCall('Advapi32.dll', 'long', 'RegEnumKeyExW', 'long', $hKey, 'dword', $iInstance - 1, 'wstr', "", 'dword*', 255, 'dword', "", 'ptr', "", 'dword', "", 'ptr', $lpftLastWriteTime)
    If Not IsArray($aRetEnum) OR $aRetEnum[0] <> 0 Then Return SetError( 3, 0, 1)

    Local $tFILETIME2 = _Date_Time_FileTimeToLocalFileTime($lpftLastWriteTime)
    Local $localtime = _Date_Time_FileTimeToStr($tFILETIME2, 1)

    $aResult[0] = $aRetEnum[3]
    $aResult[1] = $localtime

    Return $aResult
EndFunc

 

Link to comment
Share on other sites

You can use

The GUIListViewEx created by M23 to display a list view of all of the data you want and be able to edit the data in the cell (like using Excel) and when you're done, use _GUIListViewEx_SaveListView to save the data to a file. Just use the array returned from _UninstallList to populate the listview and then let the ListViewEx UDF do all the work.

Link to comment
Share on other sites

Just click on the link to read the thread.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Quote

Just click on the link to read the thread.

Duh! My bad.

Man oh man that is going to be invaluable on my computer.

But I don't think it is suitable for what I need. Obviously I didn't explain myself properly.

I want to compile that script into an exe and run it on 4 remote computers.

For example: The program CCleaner

I want a message box to pop up that says:

either "Your copy of CCleaner version 5 is up to date"

Or "Your copy of CCleaner version 5 needs updating"

I thought create a function and input $aList then do the editing in that function?

Edited by Bettylou
Link to comment
Share on other sites

What about something like:

#include <Misc.au3>

Local $sRegUninstall32 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
Local $sRegUninstall64 = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall\"

_RegSearch($sRegUninstall32, "AutoIt v3.3.14.2", "3.3.14.2")
_RegSearch($sRegUninstall64, "AutoIt v3.3.14.2", "3.3.14.2")

Func _RegSearch($sRegHive, $sDisplayName, $sDisplayVersion)
    Local $i = 1, $sRegKey
    While 1
        $sRegKey = RegEnumKey($sRegHive, $i)
            If @error Then ExitLoop
        If RegRead($sRegHive & $sRegKey, "DisplayName") = $sDisplayName Then
            If _VersionCompare(RegRead($sRegHive & $sRegKey, "DisplayVersion"), $sDisplayVersion) = 0 Then
                MsgBox(48,'Equal Version', $sDisplayName & " " & $sDisplayVersion & " is up-to-date.")
            ElseIf _VersionCompare(RegRead($sRegHive & $sRegKey, "DisplayVersion"), $sDisplayVersion) = 1 Then
                MsgBox(48,'Greater Version', "You have a later version then " & $sDisplayName & " " & $sDisplayVersion)
            ElseIf _VersionCompare(RegRead($sRegHive & $sRegKey, "DisplayVersion"), $sDisplayVersion) = -1 Then
                MsgBox(48,'Lesser Version', "Your version of " & $sDisplayName & " " & $sDisplayVersion & " is out of date.")
            EndIf
        EndIf
        $i += 1
    WEnd
EndFunc

 

Link to comment
Share on other sites

  • Developers

Maybe something more to play with:

#include <Misc.au3>

Local $sRegUninstall32 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
Local $sRegUninstall64 = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall\"

_RegSearch($sRegUninstall32, "AutoIt", "3.3.14.2")
_RegSearch($sRegUninstall64, "AutoIt", "3.3.14.2")

Func _RegSearch($sRegHive, $sDisplayName, $sDisplayVersion)
    Local $i = 1, $sRegKey
    While 1
        $sRegKey = RegEnumKey($sRegHive, $i)
        If @error Then ExitLoop
        $RegDisplayName = RegRead($sRegHive & $sRegKey, "DisplayName")
        If StringInStr($RegDisplayName, $sDisplayName) Then
            $RegVersion = RegRead($sRegHive & $sRegKey, "DisplayVersion")
            Switch _VersionCompare($RegVersion, $sDisplayVersion)
                Case 0
                    MsgBox(48, 'Equal Version', $sDisplayName & " " & $sDisplayVersion & " is up-to-date.")
                Case 1
                    MsgBox(48, 'Higher Version', "You have a later version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion)
                Case -1
                    MsgBox(48, 'Lower Version', "You have an older version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion)
            EndSwitch
        EndIf
        $i += 1
    WEnd
EndFunc   ;==>_RegSearch

This does a partial search for you can get more hits as result.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thanks Jos I can certainly "play" with that. :)

One add on I can think of right away is what to tell the operator if the program is not installed.

 

On another note - anyone -

an array with 7 columns - I only want to print  out 2 columns - which is the better to use - array extract or column delete?

Link to comment
Share on other sites

BettyLou,

Just print them...

#include <array.au3>

local $aArray[20][13]

for $1 = 0 to ubound($aArray) - 1
    for $2 = 0 to ubound($aArray,2) - 1
        $aArray[$1][$2] = $1 & '-' & $2
    Next
Next

_arraydisplay($aArray)

; print col 3, 7 and 9

local $str
for $1 = 0 to ubound($aArray) - 1
    $str &= $aArray[$1][2] & '|' & $aArray[$1][6] & '|' & $aArray[$1][8] & @CRLF
Next

ConsoleWrite($str & @CRLF)

kylomas

P.S. This link has interesting info for listing all installed programs for multiple pc's and comparing them. 

 

 

Edited by kylomas
additional info

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

@Bettylou The code Jos and I posted doesn't include an array, normally you know the name and version of software you want installed for your users which is why I used the full display name, for example if you just use partial like "AutoIt" it would notify on every instance of the word, so "Scite for AutoIt", "AutoIt Beta" etc...

Below is the code, to detect if no items are found, I've also added an Array for all items, just items you want to search for.

#include <Array.au3>
#include <Misc.au3>

Local $bRegInstall = False
Local $aRegItem[0][2]
Local $aRegInfo[0][2]
Local $sRegUninstall32 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
Local $sRegUninstall64 = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall\"

_RegSearch($sRegUninstall32, "AutoIt", "3.3.14.2")
_RegSearch($sRegUninstall64, "AutoIt", "3.3.14.2")
If $bRegInstall = False Then MsgBox(48, 'No Version', "AutoIt v3.3.14.2 is not installed.")

_ArrayDisplay($aRegInfo, "All Items")
_ArrayDisplay($aRegItem, "Search Items")

Func _RegSearch($sRegHive, $sDisplayName, $sDisplayVersion)
    Local $i = 1, $sRegKey
    While 1
        $sRegKey = RegEnumKey($sRegHive, $i)
        If @error Then ExitLoop
        $RegDisplayName = RegRead($sRegHive & $sRegKey, "DisplayName")
        If $RegDisplayName <> "" Then _ArrayAdd($aRegInfo, $RegDisplayName & "|" & RegRead($sRegHive & $sRegKey, "DisplayVersion"))
        If StringInStr($RegDisplayName, $sDisplayName) Then
            $bRegInstall = True
            _ArrayAdd($aRegItem, $RegDisplayName & "|" & RegRead($sRegHive & $sRegKey, "DisplayVersion"))
            $RegVersion = RegRead($sRegHive & $sRegKey, "DisplayVersion")
            Switch _VersionCompare($RegVersion, $sDisplayVersion)
                Case 0
                    MsgBox(48, 'Equal Version', $sDisplayName & " " & $sDisplayVersion & " is up-to-date.")
                Case 1
                    MsgBox(48, 'Higher Version', "You have a later version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion)
                Case -1
                    MsgBox(48, 'Lower Version', "You have an older version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion)
            EndSwitch
        EndIf
        $i += 1
    WEnd
EndFunc   ;==>_RegSearch

 

Link to comment
Share on other sites

Hey thanks everyone. all this help is great. It is going to take me a while to work through it all.

kylomas
That looks much more tidy and readable.
A question --- to extract particular data is it better to send $str to the console or a temp txt file?

subz
Your coding of the uninstalled is much better than mine. I was fiddling with:
If @error Then
-----

To tidy up any display names or versions I can always add:
If display name string " so and so" then
----


Edited by Bettylou
Link to comment
Share on other sites


Hi all. I've got a brain freeze. sometimes I wonder if I've got a brain.

to run the script in post #1 - will this work?

2 strings --- string1 = list of all the programs (I've got that spot on) - string2 = list of the programs I want to keep an eye on.

Local $aList = _UninstallList("", "","Publisher|InstallLocation|DisplayVersion")

Local $string1
for $1 = 0 to ubound($aList) - 1
    $string1 &= $aList[$1][2] & " " & $aList[$1][6] & @CRLF
Next

Local $string2 = "CCleaner", "5.29", "Adobe Reader XI", "10.0.20", "Mozilla Firefox", "55", "HitmanPro", "3.7"

compare strings and extract all dupes to a third string $string3

ConsoleWrite($string3 & @CRLF)

subz script

can I replace _RegSearch($sRegUninstall32, "Adobe Reader XI", "12.0.20") with a list of the programs I want to keep an eye on or a string of them?

In the switch can I replace message box with a string = $sDisplayName & " " & $sDisplayVersion & " is up-to-date."

so I can tidy up the output
for example:
"Adobe Reader XI", "12.0.20" MUI "11.0.20" is out of date

delete MUI

 

Edited by Bettylou
Link to comment
Share on other sites

Try:

Create filename.ini

[Software]
;Search_DisplayName = DisplayVersion
AutoIt v3.3.14.2 = 3.3.14.2
CCleaner = 5.29
Adobe Reader XI = 10.0.20
Mozilla Firefox = 55

;Optional Sections[Search_DisplayName.DisplayVersion]
[AutoIt v3.3.14.2.3.3.14.2]
Equal = AutoIt is up-to-date
Greater = AutoIt version is newer
Lesser = AutoIt is out of date
None = AutoIt is not installed.

[Adobe Reader XI.10.0.20]
Equal = Adobe Reader XI is up-to-date
Greater = Adobe Reader XI version is newer
Lesser = Adobe Reader XI is out of date
None = Adobe Reader XI is not installed.

[Mozilla Firefox.55]
Equal = Mozilla Firefox is up-to-date
Greater = Mozilla Firefox version is newer
Lesser = Mozilla Firefox is out of date
None = Mozilla Firefox is not installed.

Updated script:

#include <Array.au3>
#include <Misc.au3>

Local $sIniFileName = @ScriptDir & "\Filename.ini"
Local $aIniFileName = IniReadSection($sIniFileName, "Software")
    If @error Then Exit

Local $bRegInstall = False
Local $aRegItem[0][2]
Local $aRegInfo[0][2]
Local $sRegUninstall32 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
Local $sRegUninstall64 = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall\"

For $x = 1 To $aIniFileName[0][0]
    _RegSearch($sRegUninstall32, $aIniFileName[$x][0], $aIniFileName[$x][1])
    _RegSearch($sRegUninstall64, $aIniFileName[$x][0], $aIniFileName[$x][1])
    If $bRegInstall = False Then MsgBox(48, 'No Version', IniRead($sIniFileName, $aIniFileName[$x][0] & "." & $aIniFileName[$x][1], "None", $aIniFileName[$x][0] & " is not installed."))
Next

_ArrayDisplay($aRegInfo, "All Items")
_ArrayDisplay($aRegItem, "Search Items")

Func _RegSearch($sRegHive, $sDisplayName, $sDisplayVersion)
    Local $i = 1, $sRegKey
    While 1
        $sRegKey = RegEnumKey($sRegHive, $i)
        If @error Then ExitLoop
        $RegDisplayName = RegRead($sRegHive & $sRegKey, "DisplayName")
        If $RegDisplayName <> "" Then _ArrayAdd($aRegInfo, $RegDisplayName & "|" & RegRead($sRegHive & $sRegKey, "DisplayVersion"))
        If StringInStr($RegDisplayName, $sDisplayName) Then
            $bRegInstall = True
            _ArrayAdd($aRegItem, $RegDisplayName & "|" & RegRead($sRegHive & $sRegKey, "DisplayVersion"))
            $RegVersion = RegRead($sRegHive & $sRegKey, "DisplayVersion")
            Switch _VersionCompare($RegVersion, $sDisplayVersion)
                Case 0
                    MsgBox(48, 'Equal Version', IniRead($sIniFileName, $sDisplayName & "." & $sDisplayVersion, "Equal", $sDisplayName & " " & $sDisplayVersion & " is up-to-date."))
                Case 1
                    MsgBox(48, 'Higher Version', IniRead($sIniFileName, $sDisplayName & "." & $sDisplayVersion, "Greater", "You have a later version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion))
                Case -1
                    MsgBox(48, 'Lower Version', IniRead($sIniFileName, $sDisplayName & "." & $sDisplayVersion, "Lesser", "You have an older version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion))
            EndSwitch
        EndIf
        $i += 1
    WEnd
EndFunc   ;==>_RegSearch

 

Link to comment
Share on other sites

Hi subz
thanks for all the help man.

I'll take this away and see what I can do with it.
I admit I don't know much about ini files but will the script still work if the remote computers don't have that particular ini file installed? Those computers don't have autoit installed.

Link to comment
Share on other sites

I'm assuming you['re going to compile the script into an exe, so you could use FileInstall to copy the ini file to the machine, however if the computers are in a domain then you can just use a share to run from, without copying anything to the local system.

Link to comment
Share on other sites

Hi Subz

Yes it's compiled and uploaded to our web site.

There aren't many programs so will this work?
 

_RegSearch($sRegUninstall32, "CCleaner", "5.5")
_RegSearch($sRegUninstall64, "CCleaner", "5.5")
If $bRegInstall = False Then MsgBox(48, 'No Version', "CCleaner 5.39 is not installed")

_RegSearch($sRegUninstall32, "HitmanPro", "5.7")
_RegSearch($sRegUninstall64, "HitmanPro", "5.7")
If $bRegInstall = False Then MsgBox(48, 'No Version', "HitmanPro 5.7 is not installed")

And change the switch to ---


 

Switch _VersionCompare($RegVersion, $sDisplayVersion)
                Case 0
                   $script =  $sDisplayName & " " & $sDisplayVersion & " is up-to-date."
                Case 1
                   $script =  $RegDisplayName & "/" & $RegVersion & " is out of date" & "==> " &  "Latest version is " & $sDisplayVersion

    Case -1
                    $script = "You have an older version of " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion)

Then I could edit it after the switch and filewrite the result.

This script from jguinch is ok up to a point but it doesn't actually list the version that is on the machine and it gives a lot more info than I need.

this post
 

Edited by Bettylou
Link to comment
Share on other sites

You could modify jguinch code to get the version, just change the _IsInstalled function to return the $aAppList which includes the Registry Hive, Guid, Display Name, Display Version, Install Time

Alternatively you can use the changes in your last post, or place all of the apps into an array and then loop through it and write the changes to a file, for example:

#include <Array.au3>
#include <Misc.au3>

Local $bRegInstall = False
Local $aRegItem[0][2]
Local $aRegInfo[0][2]
Local $sRegUninstall32 = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\"
Local $sRegUninstall64 = "HKLM64\Software\Microsoft\Windows\CurrentVersion\Uninstall\"

Local $aAppList = [["AutoIt", "3.3.14.2"], ["CCleaner", "5.5"], ["HitmanPro", "5.7"]]
$hFileOpen = FileOpen(@ScriptDir & "\AppInfo.txt", 1)
For $i = 0 To UBound($aAppList) - 1
    _RegSearch($sRegUninstall32, $aAppList[$i][0], $aAppList[$i][1])
    _RegSearch($sRegUninstall64, $aAppList[$i][0], $aAppList[$i][1])
    If $bRegInstall = False Then FileWrite($hFileOpen, $aAppList[$i][0] & " is not installed." & @CRLF)
Next
FileClose($hFileOpen)

Func _RegSearch($sRegHive, $sDisplayName, $sDisplayVersion)
    Local $i = 1, $sRegKey
    While 1
        $sRegKey = RegEnumKey($sRegHive, $i)
        If @error Then ExitLoop
        $RegDisplayName = RegRead($sRegHive & $sRegKey, "DisplayName")
        If $RegDisplayName <> "" Then _ArrayAdd($aRegInfo, $RegDisplayName & "|" & RegRead($sRegHive & $sRegKey, "DisplayVersion"))
        If StringInStr($RegDisplayName, $sDisplayName) Then
            $bRegInstall = True
            _ArrayAdd($aRegItem, $RegDisplayName & "|" & RegRead($sRegHive & $sRegKey, "DisplayVersion"))
            $RegVersion = RegRead($sRegHive & $sRegKey, "DisplayVersion")
            Switch _VersionCompare($RegVersion, $sDisplayVersion)
                Case 0
                    FileWrite($hFileOpen, $sDisplayName & " " & $sDisplayVersion & " is up-to-date." & @CRLF)
                Case 1
                    FileWrite($hFileOpen, "You have a later version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion & @CRLF)
                Case -1
                    FileWrite($hFileOpen, "You have an older version for " & $sDisplayName & "/" & $sDisplayVersion & "==> " & $RegDisplayName & "/" & $RegVersion & @CRLF)
            EndSwitch
        EndIf
        $i += 1
    WEnd
EndFunc   ;==>_RegSearch

 

Edited by Subz
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...