Jump to content

Batch help (File version checker)


Recommended Posts

Okay I found a new way to do it - I used parts of your code and combined it with a code, that actively searches the registry keys for a certain strings and the uses the resulting positive keys to fill out the list. Positive is that this code can basically search for any string - that means for any installed program with a unique "DisplayName" - key - I do not yet know how my code deals with multiple positive matches. It prooably will only use the last positive match for the GUI... Feel free to use and improve this code - and please post it back into the Forum...

#cs ----------------------------------------------------------------------------



 AutoIt Version: 3.3.4.0

 Author:         Sönke Graf

 Program Name:   Version_Checker



 Script Function:

    This Script searches the Registry Uninstall Path - "$sBase for Specific

    Programs defined in the Variables Section under "$sSearch" - "$sSearch4" - 

    the registry is then scanned for the correct Version Number and all 

    Information stored in an array. This array then is used for a GUI display

    -ing the Information. The "$sURL" Variables are listed for an update of 

    the Software.



#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here



;=======================================================================

;                           INCLUDE CONSTANTS

;=======================================================================

#include <GuiListView.au3>

#include <Misc.au3>

#include <GUIConstantsEx.au3>

;=======================================================================

;                               VARIABLES

;=======================================================================



$sBase = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

;Five Search Operations 

$sSearch  = "Adobe Flash"

$sSearch1 = "Adobe Acrobat"

$sSearch2 = "Adobe Reader"

$sSearch3 = "Java"

$sSearch4 = "QuickTime"

;Links for latest Versions

$sURL   = "http://get.adobe.com/flashplayer/"

$sURL1  = "http://get.adobe.com/flashplayer/"

$sURL2 = "http://get.adobe.com/reader/"

$sURL3 = "http://www.java.com/download/index.jsp"

$sURL4 = "http://www.apple.com/quicktime/download/"

;=======================================================================

;                               Program Code

;=======================================================================



;-----------------------------Search Operation 1------------------------

$iEval = 1

$iSearch = 0

While 1

    $sVersion = ""

    $sDisplay = ""

    $sCurrent = RegEnumKey($sBase, $iEval)

    If @Error Then ExitLoop 

    $sKey = $sBase & $sCurrent

    $sDisplay = RegRead($sKey, "DisplayName")

    

    If StringRegExp($sDisplay, ".*" & $sSearch & ".*") Then

        $sVersion = RegRead($sKey, "DisplayVersion")

        $iSearch = 1

        If $iSearch = 1 Then

            $sStatus = "INSTALLED"

            ExitLoop

        ElseIf $iSearch = 0 Then        

            ExitLoop

        EndIf

    Endif

    $iEval += 1

WEnd

If $iSearch = 0 Then

    $sStatus = "NOT INSTALLED"

EndIf



;-----------------------------Search Operation 2------------------------

$iEval = 1

$iSearch1 = 0

While 1

    $sVersion1 = ""

    $sDisplay = ""

    $sCurrent = RegEnumKey($sBase, $iEval)

    If @Error Then ExitLoop

    $sKey = $sBase & $sCurrent

    $sDisplay = RegRead($sKey, "DisplayName")

    

    If StringRegExp($sDisplay, ".*" & $sSearch1 & ".*") Then 

        $sVersion1 = RegRead($sKey, "DisplayVersion")

        $iSearch1 = 1

        If $iSearch1 = 1 Then

            $sStatus1 = "INSTALLED"

            ExitLoop

        ElseIf $iSearch1 = 0 Then       

            ExitLoop

        EndIf

    Endif

    $iEval += 1

WEnd

If $iSearch1 = 0 Then

    $sStatus1 = "NOT INSTALLED"

EndIf



;-----------------------------Search Operation 3------------------------

$iEval = 1

$iSearch2 = 0

While 1

    $sVersion2 = ""

    $sDisplay = ""

    $sCurrent = RegEnumKey($sBase, $iEval)

    If @Error Then ExitLoop

    $sKey = $sBase & $sCurrent

    $sDisplay = RegRead($sKey, "DisplayName")

    

    If StringRegExp($sDisplay, ".*" & $sSearch2 & ".*") Then 

        $sVersion2 = RegRead($sKey, "DisplayVersion")

        $iSearch2 = 1

        If $iSearch2 = 1 Then

            $sStatus2 = "INSTALLED"

            ExitLoop

        ElseIf $iSearch2 = 0 Then       

            ExitLoop

        EndIf

    Endif

    $iEval += 1

WEnd

If $iSearch2 = 0 Then

    $sStatus2 = "NOT INSTALLED"

EndIf



;-----------------------------Search Operation 4------------------------

$iEval = 1

$iSearch3 = 0

While 1

    $sVersion3 = ""

    $sDisplay = ""

    $sCurrent = RegEnumKey($sBase, $iEval)

    If @Error Then ExitLoop

    $sKey = $sBase & $sCurrent

    $sDisplay = RegRead($sKey, "DisplayName")

    

    If StringRegExp($sDisplay, ".*" & $sSearch3 & ".*") Then 

        $sVersion3 = RegRead($sKey, "DisplayVersion")

        $iSearch3 = 1

        If $iSearch3 = 1 Then

            $sStatus3 = "INSTALLED"

            ExitLoop

        ElseIf $iSearch3 = 0 Then       

            ExitLoop

        EndIf

    Endif

    $iEval += 1

WEnd

If $iSearch3 = 0 Then

    $sStatus3 = "NOT INSTALLED"

EndIf



;-----------------------------Search Operation 5------------------------

$iEval = 1

$iSearch4 = 0

While 1

    $sVersion4 = ""

    $sDisplay = ""

    $sCurrent = RegEnumKey($sBase, $iEval)

    If @Error Then ExitLoop

    $sKey = $sBase & $sCurrent

    $sDisplay = RegRead($sKey, "DisplayName")

    

    If StringRegExp($sDisplay, ".*" & $sSearch4 & ".*") Then 

        $sVersion4 = RegRead($sKey, "DisplayVersion")

        $iSearch4 = 1

        If $iSearch4 = 1 Then

            $sStatus4 = "INSTALLED"

            ExitLoop

        ElseIf $iSearch4 = 0 Then       

            ExitLoop

        EndIf

    Endif

    $iEval += 1

WEnd

If $iSearch4 = 0 Then

    $sStatus4 = "NOT INSTALLED"

EndIf

;=======================================================================

;                       URL Detection

;=======================================================================



;=======================================================================

;                       CURRENT VERSION ARRAY

;=======================================================================

Global $aVersions[5][4]



$aVersions[0][0] = $sSearch

$aVersions[0][1] = $sStatus

$aVersions[0][2] = $sVersion

$aVersions[0][3] = $sURL



$aVersions[1][0] = $sSearch1

$aVersions[1][1] = $sStatus1

$aVersions[1][2] = $sVersion1

$aVersions[1][3] = $sURL1



$aVersions[2][0] = $sSearch2

$aVersions[2][1] = $sStatus2

$aVersions[2][2] = $sVersion2

$aVersions[2][3] = $sURL2



$aVersions[3][0] = $sSearch3

$aVersions[3][1] = $sStatus3

$aVersions[3][2] = $sVersion3

$aVersions[3][3] = $sURL3



$aVersions[4][0] = $sSearch4

$aVersions[4][1] = $sStatus4

$aVersions[4][2] = $sVersion4

$aVersions[4][3] = $sURL4







;=======================================================================

;                           CREATE GUI

;=======================================================================

Local $msg

$GUI = GUICreate("Version Checker", 565, 180)

$listview = GUICtrlCreateListView("", 5, 5, 550, 160)

_GUICtrlListView_AddColumn($listview, "Program Name", 100)

_GUICtrlListView_AddColumn($listview, "Status", 95)

_GUICtrlListView_AddColumn($listview, "Current Version", 95)

_GUICtrlListView_AddColumn($listview, "Link", 260)



For $i = 0 To UBound($aVersions) - 1

    $x = _GUICtrlListView_AddItem($listview, $aVersions[$i][0])

    _GUICtrlListView_AddSubItem($listview, $x, $aVersions[$i][1], 1)

    _GUICtrlListView_AddSubItem($listview, $x, $aVersions[$i][2], 2)

    _GUICtrlListView_AddSubItem($listview, $x, $aVersions[$i][3], 3)

Next

GUISetState(@SW_SHOW)



While 1

    $nMsg = GUIGetMsg()

    Select

        Case $nMsg = $GUI_EVENT_CLOSE

            MsgBox(0, "", "Dialog was closed")

            Exit

        Case $nMsg = $GUI_EVENT_MINIMIZE

            MsgBox(0, "", "Dialog minimized", 2)

        Case $nMsg = $GUI_EVENT_MAXIMIZE

            MsgBox(0, "", "Dialog restored", 2)

    EndSelect

WEnd
Link to comment
Share on other sites

Hey guys,

After a few days of playing wiht the code i belive i have it ready to roll. I have given the program a short name for now - Friple. lol as more and more of my team use this they have asked for some differnt functionality's; remote use and maybe a timestamp of when it was last run. I think it would be very handy to have it run on a remote machine. What could i use for this remote funcatinality or is that to much to try and tackle? I dont think the timestamp of last time the aplication was run shouldnt be to hard. Maybe take something in the registry and have it read that as a variable?

Link to comment
Share on other sites

Also I have noticed that once a few people start using this, it wont allow me to delete it while someone uses it. What if it gets started on a machine and forgotten about? how can i update it without having to kick everyone off who is using the file. Any thoughts?

-Frank

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...