VBscript to Install Adobe Acrobat

September 2, 2010 at 05:37:20
Specs: Windows Vista
I have a VB script to install Adobe based on its current patch level. I am trying to make sure that it patches Acrobat to the most current but with adobe you have to do the patches in Sequences. The problem is it seems to work if the application is already on 9.3.3. It will patch them to 9.3.4, What am I doing wrong that is not catching all the other versions ?


set objshell = createobject("wscript.shell")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32Reg_AddRemovePrograms " & _
"WHERE DisplayName LIKE '%Adobe Acrobat 9 Pro%' OR DisplayName LIKE '%Adobe Acrobat 9 Std%'", _
"WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)


For Each objItem In colItems
acro = InStr(objItem.DisplayName,"Adobe Acrobat")
If (acro = 1) Then
acroVer = objItem.Version
End if


Select Case acroVer
Case "9.3.0"
instStr = "msiexec.exe /p """ _
& fSource & "AcrobatUpd932_all_incr.msp;" _
& fSource & "AcrobatUpd933_all_incr.msp;" _
& fSource & "AcrobatUpd934_all_incr.msp""" & _
" REINSTALLMODE=omus REINSTALL=ALL /qn /norestart"
Case "9.3.1"
instStr = "msiexec.exe /p """ _
& fSource & "AcrobatUpd932_all_incr.msp;" _
& fSource & "AcrobatUpd933_all_incr.msp;" _
& fSource & "AcrobatUpd934_all_incr.msp""" & _
" REINSTALLMODE=omus REINSTALL=ALL /qn /norestart"
Case "9.3.2"
instStr = "msiexec.exe /p """ _
& fSource & "AcrobatUpd933_all_incr.msp;" _
& fSource & "AcrobatUpd934_all_incr.msp""" & _
" REINSTALLMODE=omus REINSTALL=ALL /qn /norestart"

Case "9.3.3"
instStr = "msiexec.exe /p """ _
& fSource & "AcrobatUpd934_all_incr.msp""" & _
" REINSTALLMODE=omus REINSTALL=ALL /qn /norestart"

Case Else
If (Left(acroVer,3) <> "9.3") Then
instStr = "msiexec.exe /p """ _
& fSource & "AcroProStdUpd910_T1T2_incr.msp;" _
& fSource & "AcrobatUpd932_all_incr.msp;" _
& fSource & "AcrobatUpd933_all_incr.msp;" _
& fSource & "AcrobatUpd934_all_incr.msp""" & _
" REINSTALLMODE=omus REINSTALL=ALL /qn /norestart"
End If
End Select

objshell.run instStr, 0, true

Next


'--------------------------------------
'-- Check to ensure version is current
'--------------------------------------

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32Reg_AddRemovePrograms " & _
"WHERE DisplayName LIKE '%Adobe Acrobat 9 Pro%' OR DisplayName LIKE '%Adobe Acrobat 9 Std%'", _
"WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
If objItem.Version <> "9.3.4" Then Wscript.Quit(1) 'If not current version then exit with error 1
Next


See More: VBscript to Install Adobe Acrobat

Report •


#1
September 2, 2010 at 07:43:10
I'm pretty sure you can't define multiple .MSP files to run like that, which would explain why only the "one patch" path runs. I'd probably do something like this, but I can't test it because I'm on WinXP. (Win32Reg_AddRemovePrograms was introduced sometime between Win2K3 and Vista.)

Also: You're using the var "fSource," but you never define its contents. Presumably you just didn't copy that line from your script.

And: Learn how to use LIKE.

patches = Array("AcroProStdUpd910_T1T2_incr.msp", _
                "AcrobatUpd932_all_incr.msp", _
                "AcrobatUpd933_all_incr.msp", _
                "AcrobatUpd934_all_incr.msp")
patchLevel = UBound(patches) + 1
acroVer = ""
Const wbemFlagReturnImmediately = 16
Const wbemFlagForwardOnly = 32

set objshell = createobject("wscript.shell")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32Reg_AddRemovePrograms " & _
  "WHERE DisplayName LIKE 'Adobe Acrobat 9%'", _
  "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)


For Each objItem In colItems
  acroVer = objItem.Version
Next

  Select Case acroVer
  Case "9.3.0"
    patchLevel = 1
  Case "9.3.1"
    patchLevel = 1
  Case "9.3.2"
    patchLevel = 2
  Case "9.3.3"
    patchLevel = 3
  Case Else
    If (Left(acroVer,3) <> "9.3") Then
      patchLevel = 0
    End If
  End Select

  For i = patchLevel To UBound(patches)
    objshell.run "msiexec.exe /p """ & fSource & patches(i) & _
      """ REINSTALLMODE=omus REINSTALL=ALL /qn /norestart", 0, true
  Next 'i



'--------------------------------------
'-- Check to ensure version is current
'--------------------------------------

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32Reg_AddRemovePrograms " & _
  "WHERE DisplayName LIKE 'Adobe Acrobat 9%'", _
  "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
  WScript.Quit (objItem.Version <> "9.3.4") And 1 'If not target version then exit with error 1
Next


Report •

#2
October 11, 2010 at 13:06:03
Did you ever get this working? I'm trying to accomplish the same thing and would love to know!

Report •
Related Solutions


Ask Question