Jump to content

Check fileversion read part of version and report


Recommended Posts

Hello again

Question from a beginner.

Was wondering what the smart method of checking the version of a file and if the say the version is 10,0,38,17 but you want to narrow down to just the first part "10" how would you do this and if it is 10 or greater then okay if less than 10 then error out?

Currently i want to check the version of flash installed but i kind of want to future proof my error checking.

I thought about doing a simple

If not filexist("C:\WINDOWS\system32\Macromed\Flash\Flash10c.ocx")

then
msgbox(0, "", "Adobe Flash player 10 or above" & @crlf & "is not present on this machine" & @crlf & @crlf & "please contact IT")
Exit
Endif

but doesn't leave much room for future roll outs of flash player.

I have looked at checking the registry also

HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayer

but again if i check for "Exacts" then if version 10,0,38,98 is released and installed on local machine then it will error out.

if registry is the way to go could you say if the first two digits where read and are 10 or greater then all is okay to continue with script?

as mentioned i'm still a beginner to Autoit so any assistance and where exactly i would check in the help file would be great

Thanks in advance

ftc

Link to comment
Share on other sites

Hello again

Question from a beginner.

Was wondering what the smart method of checking the version of a file and if the say the version is 10,0,38,17 but you want to narrow down to just the first part "10" how would you do this and if it is 10 or greater then okay if less than 10 then error out?

Currently i want to check the version of flash installed but i kind of want to future proof my error checking.

I thought about doing a simple

If not filexist("C:\WINDOWS\system32\Macromed\Flash\Flash10c.ocx")

then
msgbox(0, "", "Adobe Flash player 10 or above" & @crlf & "is not present on this machine" & @crlf & @crlf & "please contact IT")
Exit
Endif

but doesn't leave much room for future roll outs of flash player.

I have looked at checking the registry also

HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayer

but again if i check for "Exacts" then if version 10,0,38,98 is released and installed on local machine then it will error out.

if registry is the way to go could you say if the first two digits where read and are 10 or greater then all is okay to continue with script?

as mentioned i'm still a beginner to Autoit so any assistance and where exactly i would check in the help file would be great

Thanks in advance

ftc

Hi,

have a look in helpfile for iniread & write functions. You can create an application for checking several fileversions....

1) Create an ini file with following structure:

version=10.0.38.98

Save it as version.ini in the Scriptdirectory. Later you should place it on a central share storage....

2) Code:

; you may use a central store ini file, e.g instead of @ScriptDir & "\flashversion.ini" "\\myserver\share\flashversion.ini
; if you have a central store ini, check if you have access to share, if not exit program
If FileExists (@ScriptDir & "\version.ini") Then
    $ver_it_shouldbe = IniRead (@ScriptDir & "\version.ini", "flash", "version", "") 
Else
    Exit
EndIf
If FileExists (@SystemDir & "\Macromed\Flash\Flash10c.ocx") Then
    $ver = FileGetVersion (@SystemDir & "\Macromed\Flash\Flash10c.ocx")
    If $ver <> $ver_it_shouldbe Then
        ;coding for install newversion
        _mymessage ()
    Else
        ;Version o.k
        Exit
    EndIf
Else
    ;No Flash install coding for install version
    _mymessage ()
EndIf

Func _mymessage ()
    MsgBox (0,"","Adobe Flash player 10 or above" & @crlf & "is not present on this machine" & @crlf & @crlf & "please contact IT")
EndFunc
Edited by 99ojo
Link to comment
Share on other sites

Hi

I use a vbs Script for Adobe Flash Player. But you can translate it to Autoit.

This works for me:

'Start Script Read Version
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
objReg.GetStringValue HKEY_LOCAL_MACHINE, strRoot, strRegKey, strWert

If strWert <> strFileVersionCheck Then 
    Wscript.echo "Need Update Current Version: " &  strWert
Else 
    Wscript.echo "No Update need Current Version: " &  strWert
    Wscript.Quit
End If

Complete Script

Option Explicit

Dim objWMIService, objProcess, objCalc, fso, objReg
Dim strComputer, strFileVersion, strFileVersionCheck, strRoot, strRegKey, strWert
Dim strShell, objProgram, strExe, strPatchfile, strFrom, strTo, strPatchScript, ProcessRunning

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = Inputbox("Enter Computername to force updates","Force Flash Updates")
    If strComputer = "" Then WScript.quit
On Error GoTo 0

'Muss angepasst werden ...
strPatchfile = "install_flash_player_10_active_x fuer_ie.exe"
strFileVersionCheck = "10,0,32,19"
strRoot = "SOFTWARE\Macromedia\FlashPlayer"
strRegKey = "CurrentVersion"

'Muss nicht angepasst werden
strFrom = strPatchfile
strTo = "\\" & strComputer & "\c$\"
strPatchScript = "\\"& strComputer & "\c$\" & strPatchfile
strExe = "c:\" & strPatchfile & " /silent /passive /norestart"


'Start Script Read Version
Set objReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
objReg.GetStringValue HKEY_LOCAL_MACHINE, strRoot, strRegKey, strWert

If strWert <> strFileVersionCheck Then 
    Wscript.echo "Need Update Current Version: " &  strWert
Else 
    Wscript.echo "No Update need Current Version: " &  strWert
    Wscript.Quit
End If 


Function IsProcessRunning( strServer, strProcess )
    Dim Process, strObject
    ProcessRunning = False
    strObject   = "winmgmts://" & strServer
    For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
    If UCase( Process.name ) = UCase( strProcess ) Then
            ProcessRunning = True
            Exit Function
        End If
    Next
End Function


'Copy Patchfile to Client
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strPatchScript) Then fso.DeleteFile strPatchScript, true
fso.CopyFile strFrom , strTo 


'Start Flash Installer
If Not fso.FileExists(strPatchScript) Then
    Wscript.Quit
End If
set objWMIService = getobject("winmgmts://" & strComputer & "/root/cimv2")
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe
Set strShell = objWMIService.ExecMethod("Win32_Process", "Create", objProgram)


'Check if Process is running
WScript.Sleep 2000 
Do 
    IsProcessRunning strComputer, strPatchfile 
    WScript.Sleep 5000
Loop Until ProcessRunning = False


'Delete remote install File
fso.DeleteFile strPatchScript, true
set fso = nothing

objReg.GetStringValue HKEY_LOCAL_MACHINE, strRoot, strRegKey, strWert
WScript.echo "Flash Player installation auf " & strComputer & " fertig !!! " & strWert
WSCript.Quit
Edited by Tec
Link to comment
Share on other sites

  • 2 weeks later...

try FileGetVersion

Not sure if you are trying to bump your own post count :) lol, but filegetversion is limited (to what i am able to do with it) specially when Flash player installs multiple files in a target directory and some of the files may or may not exist but still work. as explained in my OP.

If i was to do a Filegetversion("c:\Windows\system32\macromed\flash\flashutil10c.exe") or any file currently present in that directory, it would not allow for future proofing the application. so if in 5mnths time flash10d.RC3 is present or flash11.RC3 or if an old install flash.exe.

The files maybe replaced with a new install but the registry entry still remain for backwards compatibility and indicates there is a either a equal or greater version on the system.

Anyway i found a solution and it is checking if for Specific registry entry "HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash.10" regardless of updates etc etc this entry should remain.

Thanks for ideas anyways :) and hope this may help others as a stepping stone

ftc

Link to comment
Share on other sites

i'm trying to do more or less the same exact thing.

I'm trying to check the version of Adobe Flash player and do something if the latest version isn't installed. I'm running into the same exact problem with the flashutil10c.exe as opposed to flashutil9b.exe etc.

I'm trying to figure out how you used the "HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash.10" to check the version. I understand that if Flash 9 is installed then obviously shockwaveFlash.10 won't be present.

Can you post your code?

thanks

Link to comment
Share on other sites

  • 2 weeks later...

i'm trying to do more or less the same exact thing.

I'm trying to check the version of Adobe Flash player and do something if the latest version isn't installed. I'm running into the same exact problem with the flashutil10c.exe as opposed to flashutil9b.exe etc.

I'm trying to figure out how you used the "HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash.10" to check the version. I understand that if Flash 9 is installed then obviously shockwaveFlash.10 won't be present.

Can you post your code?

thanks

Sorry late reply to your post have had this project on back burner.

I am implementing it this way as when flash player 10, plus future releases are installed on target machine it allows for backward compatibility with adding in previous versions of flash to the registry.

if RegRead("HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash.10", "") Then
    _fileinstall ()
ElseIf Not RegRead("HKEY_CLASSES_ROOT\ShockwaveFlash.ShockwaveFlash.10", "") Then
    msgBox(0, "Missing Flash Player", "Adobe Flash player 10 or above" & @crlf & "is not present on this machine" & @crlf & @crlf & "please contact Helpdesk" & _
    @CRLF & "Phone Number")
    Exit
EndIf

It is pretty basic but has room to "move" instead of checking file versions on a single or multiple file which can change every time a new patch is installed.

I Will change the Regread to read from a .ini , so if adobe wants to remove old reg entries in version 12 or whatever i can just update the .ini

ftc

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