Script to Check Adobe Version and update if needed

Here you are Mike, I’ve played with a few scripts and had great results… but this one has to be my crowning achievement at this point.

Some background info first: We needed most of our PCs to have Adobe Reader version 8.1.4 installed. We have automatic updates for adobe blocked on the firewall, and we also couldn’t install 9.0 because it would not be supported by another piece of software. Some of the PCs still had adobe reader 7.0, most had 8.0 or 8.1. I wanted a script that got called in a login script and checked what version they had and ran a silent install of adobe 8.1.4 if needed.

First, I got myself a full exe of Adobe 8.1.3 (for some annoying reason you can only patch to 8.1.4 from 8.1.3, and there is no full install of 8.1.4). I used resources that adobe themselves provide to make a custom msi package and also set it to include the separate 8.1.4 patch. This all gets dumped into a directory on a network share that all users have access to.

I then added this line to the users login scripts (batch files) to call the script:

cscript “\\LocalServer\share\folder\adberdr81Silent\setup files\adobe814.vbs” /quiet /passive

This calls the script silently and does not ask the user if they want to run or whatever other BS safety messages Windows XP vomits at you normally when you run a file off the network.

Now the VBscript (script in blue, my comments for this post in normal):

Dim FilePath
Dim fso
Dim version
Dim WshShell

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

If objFSO.FileExists(“c:\program files\adobe\reader 8.0\reader\acrord32.exe”) Then
Set objNet = WScript.CreateObject(“WScript.Network”)
strCaption = “Adobe Reader”
Set objWMI = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2”)
For Each objSoftware in objWMI.ExecQuery(“SELECT * FROM Win32_Product Where Caption Like ‘%” & strCaption & “%'”)
version = objSoftware.Version
Next

^ This says look to see if the folder for adobe 8.0 exists on the local C:, and if it does, it searches the registry for what exact version it is and stores it in the “version” variable. If the folder for 8.0 does not exist, the script can assume that either 7.0 is installed, or no version of adobe is installed and will run the setup in the “else” option below:

Else

set objWshShell= CreateObject(“Wscript.Shell”)
set objEnviroment = objWshShell.Environment(“PROCESS”)
objEnviroment (“SEE_MASK_NOZONECHECKS”) = 1

^ This changes the registry so that it will disable those annoying open file warnings during the script

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WScript.Echo WshShell.CurrentDirectory
WshShell.CurrentDirectory = “Y:\folder\adberdr81Silent\Setup Files”

^ This changes the running directory (I had trouble with some stations thinking I was trying to run setup.exe out of the windows directory, this fixed that) Y: is mapped to the “share” on the local server.

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WshShell.Run “setup.exe”

set objWshShell= CreateObject(“Wscript.Shell”)
set objEnviroment = objWshShell.Environment(“PROCESS”)
objEnviroment (“SEE_MASK_NOZONECHECKS”) = 0

WScript.quit

^ This calls the setup.exe located in that folder and the custom adobe msi I made to install completely silently (among other custom settings) takes it from here. Then the script undoes the change I made to disable the open file warnings and exits the script. Adobe 8.1.4 is now installed.

End If

If version = “8.1.4” Then

WScript.quit

^ Here we have the other option, the script finds the adobe 8.0 directory and is now going to check that version variable. For my purposes, checking if the version is 8.1.4 (highest version of reader 8 ) is what I needed. If that version is already installed the script quits and does nothing further.

Else

set objWshShell= CreateObject(“Wscript.Shell”)
set objEnviroment = objWshShell.Environment(“PROCESS”)
objEnviroment (“SEE_MASK_NOZONECHECKS”) = 1

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WScript.Echo WshShell.CurrentDirectory
WshShell.CurrentDirectory = “Y:\folder\adberdr81Silent\Setup Files”

Set WshShell = WScript.CreateObject(“WScript.Shell”)
WshShell.Run “setup.exe”

set objWshShell= CreateObject(“Wscript.Shell”)
set objEnviroment = objWshShell.Environment(“PROCESS”)
objEnviroment (“SEE_MASK_NOZONECHECKS”) = 0

WScript.quit

end if

^ Otherwise, if Adobe reader 8 is found, but does not equal version 8.1.4, then the script updates it to the version required by running the silent setup. From that point the setup.exe is smart enough to just install the patch(es) needed. Adobe made these easy to customize.

So there you have it. This script was added to the login process and if the PC didn’t already have Adobe Reader 8.1.4, it would install it. Otherwise it would not do anything. Either way the end user had no idea it was happening. I’m sure this script is sloppy, but it did exactly what I needed it to do – and saved Celeste and I a shitload of tedious work – , so I was pleased.

-Dave out

Advertisements

4 thoughts on “Script to Check Adobe Version and update if needed

  1. Awsome write up. Is there a Version 9 available? I am going to try to modify this one but not sure if I will succeed. Either way nice work!

  2. We still avoid using Adobe reader version 9 at my place of work, so I haven’t worked on anything like this for an upgrade to version 9. But, I would think that it would be fairly easy to modify my script to do what you want.

    The key part is actually creating the custom msi package with the tools that adobe provide free of cost. You can create an installer that runs silently, and even sets the default settings that you desire (for example, turning off automatic updates and removing the splash welcome screen). That part is actually pretty easy.

    Once you have that setup the way you wish, it is a simple matter of getting it delivered to, and only to, the PCs you want it installed on.

    One of the major reasons I had to write this .vbs to begin with was because that if the installer I created tried to run on a station that already had that adobe version on it, the silent feature would fail because the installer would then try to launch in “repair mode”. This was unacceptable, as it meant the end user getting a installer dialog as they signed in. Having zero user involvement was job number 1.

    So keep those things in mind, and good luck.

  3. Updated the Code for Version 10.2 Just need to change the first three lines. It would be even better, if I could figure out how to find an .exe in a share folder, and would just look at the exe. A person could then use Ketarin to check for latest update and then download the latest update to that folder, and then the script would check to ensrue that it’s the latest version all of the time.

    Dim FilePath
    Dim fso
    Dim version
    Dim WshShell
    Dim strAdobeReaderPath
    Dim strAdobeInstallDir
    Dim strAdobeSilentInstallcmd
    Dim strAdobeCurVersion
    Dim OSArch

    strAdobeInstallDir = “\\SHAREPATH”
    strAdobeSilentInstallcmd=”AdbeRdr1012_en_US.exe /msi EULA_ACCEPT=YES /qn”
    strAdobeCurVersion=”10.1.2″
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    OSArch=WshShell.RegRead(“HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE”)
    If OSArch = “x86″ then
    strAdobeReaderPath=”c:\program files\adobe\reader 10.0\reader\acrord32.exe”
    ElseIf OSArch = “x64″ then
    strAdobeReaderPath=”c:\program files(x86)\adobe\reader 10.0\reader\acrord32.exe”
    end if

    If objFSO.FileExists(strAdobeReaderPath) Then
    Set objNet = WScript.CreateObject(“WScript.Network”)
    strCaption = “Adobe Reader”
    Set objWMI = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2”)
    For Each objSoftware in objWMI.ExecQuery(“SELECT * FROM Win32_Product Where Caption Like ‘%” & strCaption & “%'”)
    version = objSoftware.Version
    Next

    msgbox version

    Else

    set objWshShell= CreateObject(“Wscript.Shell”)
    set objEnviroment = objWshShell.Environment(“PROCESS”)
    objEnviroment (“SEE_MASK_NOZONECHECKS”) = 1
    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    WScript.Echo WshShell.CurrentDirectory
    WshShell.CurrentDirectory = strAdobeInstallDir
    ‘Silent Install Switch “AdbeRdr1012_en_US.exe /msi EULA_ACCEPT=YES /qn”
    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    WshShell.Run strAdobeSilentInstallcmd

    set objWshShell= CreateObject(“Wscript.Shell”)
    set objEnviroment = objWshShell.Environment(“PROCESS”)
    objEnviroment (“SEE_MASK_NOZONECHECKS”) = 0

    WScript.quit
    End If

    If version = strAdobeCurVersion Then
    ‘If the version is on the latest release
    WScript.quit
    Else

    set objWshShell= CreateObject(“Wscript.Shell”)
    set objEnviroment = objWshShell.Environment(“PROCESS”)
    objEnviroment (“SEE_MASK_NOZONECHECKS”) = 1

    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    WScript.Echo WshShell.CurrentDirectory
    WshShell.CurrentDirectory = strAdobeInstallDir

    Set WshShell = WScript.CreateObject(“WScript.Shell”)
    WshShell.Run strAdobeSilentInstallcmd

    set objWshShell= CreateObject(“Wscript.Shell”)
    set objEnviroment = objWshShell.Environment(“PROCESS”)
    objEnviroment (“SEE_MASK_NOZONECHECKS”) = 0

    WScript.quit

    end if

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s