Execute all updates in a folder if the file version is lower then the current version

Hello,
I am trying to create a script that will install all update files ending with the msp extension if the file version is lower then 9.5.4
I wrote the following script but I get that a colFiles.GetVersion method or property is not supported by this object error, what would be the correct way of addressing the task to get the version of each file in a folder

As a next step I like to check and compare the version of the file in the folder with the version of the executable file of an already installed application.



Dim WshShell, oExec, strCurrentVersion, strFileVersion
strCurrentVersion = "9.5.4"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("\\Server\ApplicationShare")
Set colFiles = objFolder.Files
Set colVersion = colFiles.GetFileVersion

	For Each objFile in colFiles 
		
		IF right(objFile.Name,3) = "msp" Then
    			IF colVersion  < strCurrentVersion Then
			
				Wscript.Echo(objFile.Path)
				'Set WshShell = CreateObject("WScript.Shell")
				'Set oExec = WshShell.Exec("msiexec /p " & objFile.path & " /norestart /qb REINSTALLMODE=ecmus REINSTALL=ALL") 'Execute Update
	
				
					'Do While oExec.Status = 0
     						'WScript.Sleep 100
					'Loop
			End IF

		End IF
		
Next

Open in new window

DavidSystems EngineerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Robberbaron (robr)Connect With a Mentor Commented:
I think you meant to type DSOFile; it doesnt exist by default though can be downloaded as you noted , including a 64bit version. http://www.keysolutions.com/blogs/kenyee.nsf/d6plinks/KKYE-79KRU6 
just need to ensure you register them correctly....  the 64bit one to win\sys32,  the 32bit one to win\syswow64

what script code are you using at the moment ?  as my work with dsofile is from an app (VB6 & C#)   is the "revision number" exposed as a Summary Property or a Custom one ?
0
 
TheNauticanConnect With a Mentor Commented:
Strangely, this has not come up before in my travels...so i had to do some research. I'm on the linux box at the moment but did find this...

http://msdn.microsoft.com/en-us/library/b4e05k97%28v=vs.84%29.aspx 

It shows passing in the file as an argument. Hope this gets you in the right direction. When i get on the windows machine I'll test this out myself. Eventually I'm sure I'll need this.

Regards,
-Naut


*** EDIT ***
This code worked just fine for me. Change to suit your needs.

Dim WshShell, oExec, strCurrentVersion, strFileVersion
strCurrentVersion = "9.5.4"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\users\aj\Downloads\")
Set colFiles = objFolder.Files
'Set colVersion = colFiles.GetFileVersion

      For Each objFile in colFiles
            
            IF right(objFile.Name,3) = "exe" Then
                      IF objFSO.GetFileVersion( objFile.Path )  < strCurrentVersion Then
                      
                      'strVersion = objFSO.GetFileVersion( objFile.Path )
                  
                        Wscript.Echo(objFile.Path)
                        Wscript.Echo(objFile.Name)
                        Wscript.Echo( objFSO.GetFileVersion( objFile.Path ) )
                        'Set WshShell = CreateObject("WScript.Shell")
                        'Set oExec = WshShell.Exec("msiexec /p " & objFile.path & " /norestart /qb REINSTALLMODE=ecmus REINSTALL=ALL") 'Execute Update
      
                        
                              'Do While oExec.Status = 0
                                         'WScript.Sleep 100
                              'Loop
                  End IF

            End IF
            
Next
0
 
Robberbaron (robr)Commented:
but the problem remains, how to get the file version of the MSP file (or its contents)

only exe and dll files seem to expose the version number.
msp files on my system have a 'revision number' under details but this is a GUID , not a version.
0
 
DavidSystems EngineerAuthor Commented:
Thank you very much Naut and Robberbaron

I am Sorry for the confusion, I completely overlooked that there is no version info on the msp files but I found on closer look the last 3 digits in the revision number from  the MSP files I am dealing with (Adobe Acrobat Updates) represent the version.

I tried to get the last 3 digits to a string using the FSOfile Object (http://technet.microsoft.com/en-us/library/ee692828.aspx) but couldn't get it to work


Not sure if this is correct, I found some info suggesting that the FSOFile.dll needed dos not exist anymore in Windows 7.
0
 
DavidSystems EngineerAuthor Commented:
Thank you, I downloaded and registered the Dll and it works very nicely now
unfortunately I might not be able to get much use out of it as the environment I like to use it in is very restrictive and distributing the dll will require to go through a bureaucratic change management  process, do you know of a way that would work with the default w7 32/64 environment?

Many Thanks!

PS: the code used

Dim WshShell, oExec, strCurrentVersion, strFileVersion, objProperty
strCurrentVersion = "953"
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder("\\Server\AppShare")
Set colFiles = objFolder.Files

      For Each objFile in colFiles 
            
            If right(objFile.Name,3) = "msp" Then
		Set objPropertyReader = CreateObject("DSOFile.OleDocumentProperties")
	    	objPropertyReader.Open(objFile.Path)
                strFileVersion = left( Right ( objPropertyReader.SummaryProperties.RevisionNumber, 4 ), 3 )
                If strFileVersion < right(strCurrentVersion,3) Then
		          
                        Wscript.Echo(objFile.Path)
                        Wscript.Echo(strCurrentVersion)
                        Wscript.Echo(objPropertyReader.SummaryProperties.RevisionNumber)
                        'Wscript.Echo( strFileVersion )
                        'Set WshShell = CreateObject("WScript.Shell")
                        'Set oExec = WshShell.Exec("msiexec /p " & objFile.path & " /norestart /qb REINSTALLMODE=ecmus REINSTALL=ALL") 'Execute Update
      
                        
                              'Do While oExec.Status = 0
                                         'WScript.Sleep 100
                              'Loop
              objPropertyReader.Close
                 End IF

            End IF
            
Next

Open in new window

0
All Courses

From novice to tech pro — start learning today.