Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-24
5
Medium Priority
?
449 Views
Last Modified: 2014-01-27
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

0
Comment
Question by:David
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Assisted Solution

by:TheNautican
TheNautican earned 1000 total points
ID: 39808054
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
 
LVL 32

Expert Comment

by:Robberbaron (robr)
ID: 39809441
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
 

Author Comment

by:David
ID: 39811542
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
 
LVL 32

Accepted Solution

by:
Robberbaron (robr) earned 1000 total points
ID: 39811679
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
 

Author Comment

by:David
ID: 39812150
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

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question