home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Minami 85
/
MINAMI85.iso
/
Extra
/
QuickTimeInstaller.exe
/
RCDATA
/
CABINET
/
AppleSoftwareUpdate.msi
/
Binary.Scripts.vbs
< prev
next >
Wrap
Text File
|
2007-02-16
|
2KB
|
66 lines
' VBScript source code
Option Explicit
' Launch condition related subroutines-----------------------------------------
Function CompareVersions(sVersion1, sVersion2)
Dim rgExpVersionComponents
Dim oMatches1, oMatches2
Dim iVersion1, iVersion2
Dim i
On Error Resume Next
Set rgExpVersionComponents = New RegExp
rgExpVersionComponents.Pattern = "(\d+)\.?"
rgExpVersionComponents.Global= True
Set oMatches1 = rgExpVersionComponents.Execute(sVersion1)
Set oMatches2 = rgExpVersionComponents.Execute(sVersion2)
i = 0
Do
Err.Clear
iVersion1 = 0
iVersion2 = 0
iVersion1 = CInt(oMatches1(i).SubMatches(0))
iVersion2 = CInt(oMatches2(i).SubMatches(0))
If iVersion1 < iVersion2 Then
CompareVersions = -1
Exit Function
ElseIf iVersion1 > iVersion2 Then
CompareVersions = 1
Exit Function
End If
i = i + 1
Loop While Err.number = 0
CompareVersions = 0
End Function
Sub PreventDowngrade
Const msiInstallStateAdvertised = 1
Dim Installer
Dim RelatedProducts
Dim UpgradeCode
Dim ProductCode
Dim ProductVersion
Dim ProductVersionMax
Dim ProductVersionFound
Set Installer = Session.Installer
ProductVersion = Session.Property("ProductVersion")
ProductVersionMax = ""
UpgradeCode = Session.Property("UpgradeCode")
Set RelatedProducts = Installer.RelatedProducts(UpgradeCode)
For Each ProductCode in RelatedProducts
If Installer.ProductState(ProductCode) = msiInstallStateAdvertised Then
ProductVersionFound = Installer.ProductInfo(ProductCode, "Version")
Else
ProductVersionFound = Installer.ProductInfo(ProductCode, "VersionString")
End If
If CompareVersions(ProductVersionFound, ProductVersionMax) > 0 Then ProductVersionMax = ProductVersionFound
Next
If CompareVersions(ProductVersionMax, ProductVersion) > 0 Then
Session.Property("BNEWERPRODUCTISINSTALLED") = "1"
Else
Session.Property("BNEWERPRODUCTISINSTALLED") = ""
End If
End Sub