I need a script to identify the version of the currently installed
Adobe Acrobat version. I already googled and found a script to list
installed software and write it to a file (from the microsoft page).
I know I can ask for the current version of a software by using:
objSoftware.Version <= 6.0
What I don't know is how to access the objSoftware object that is
responsible for the Adobe Acrobat Reader. Because the caption and
description always includes the current version number, it is not only
"Adobe Reader".
I looked in a lot of groups and websites but I couldn't find a topic
that is similar to mine!
I'm pretty new to vbscript, please don't mind if this is a stupid
question, I really appreciate your help!
thanks,
tanne
Things to watch out for:
- The Win32_Product class only detects software installed via MSI (a.k.a.
Windows Installer). Older versions of Adobe Reader did not use MSI and
won't be detected.
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_product.asp
- Adobe Reader patches will also appear in the Win32_Product class, as
separate entries from the base product.
- You should test this on as many machines as possible, with different
flavors of the full Adobe Acrobat (Exchange/Distiller), Adobe Reader, and
the older Adobe Acrobat Reader 3.x, 4.x & 5.x
Option Explicit
Dim AdobeReaderName, AdobeReaderVersion
Dim objWMI, colSoftware, objSoftware
AdobeReaderName = ""
AdobeReaderVersion = "0"
Set objWMI = GetObject("winmgmts:root\cimv2")
Set colSoftware = objWMI.ExecQuery("SELECT * FROM Win32_Product")
For Each objSoftware In colSoftware
If InStr(UCase(objSoftware.Name), "ADOBE READER") >= 1 Then
AdobeReaderName = objSoftware.Name
AdobeReaderVersion = objSoftware.Version
End If
Next
If AdobeReaderVersion >= "6" Then
WScript.Echo AdobeReaderName & " is installed."
Else
WScript.Echo "Adobe Reader 6 or later is NOT installed."
End If
"tanne" <diet...@gmx.net> wrote in message
news:1123277870.1...@g47g2000cwa.googlegroups.com...
How about this.
With CreateObject("WScript.Shell")
MsgBox .Regread("HKCR\AcroExch.Document\AcrobatVersion\")
End With
--
Miyahn (Masataka Miyashita) JPN
Microsoft MVP for Microsoft Office - Excel(Jan 2005 - Dec 2005)
HQF0...@nifty.ne.jp
>"tanne" wrote in message news:1123277870.1...@g47g2000cwa.googlegroups.com
>> I want to be able to create a CD that when inserted makes a check for
>> the current version of Acrobat Reader:
>
>How about this.
>
>With CreateObject("WScript.Shell")
> MsgBox .Regread("HKCR\AcroExch.Document\AcrobatVersion\")
>End With
Not in my registry (Acrobat 7 and Reader 7 installed). OTOH there are:
HKCR\AcroExch.App\AcrobatVersion
HKCR\AcroExch.FDFDoc\AcrobatVersion
HKCR\AcroExch.RMFFile\AcrobatVersion
HKCR\AcroExch.XDPDoc\AcrobatVersion
HKCR\AcroExch.XFDFDoc\AcrobatVersion
I don't know whether these would be present in an environment where only
the reader is installed.
Does VBS have a method to extract version information from an executable?
In 4NT, this would do the trick:
ECHO %@VERINFO[%@WORD[0,%@REGQUERY[HKCR\Applications\AcroRD32.exe\shell\Read\command\]]]
returns here: 7.0.0.0
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
Well, doesn't this work?
With CreateObject("WScript.Shell")
MsgBox .RegRead("HKCR\" & .RegRead("HKCR\.pdf\") & "\AcrobatVersion\")
Maybe you could help me with another question:
In the same script I want to start the installation of Adobe Reader.
And I want the script to wait until the installation ends and then
start
another application/program.
I already got it done by using the download exe-file from the adobe
website: AdbeRdr70_deu_full.exe
errCode = wShell.run("C:\AdbeRdr70_deu_full.exe",, TRUE)
This works but unfortunately it just waits until this special
application did run and then when the real setup starts (I can't
access this setup directly) my script is not waiting anymore!
I tried to solve it by using an .msi that I got from my computer
and code from the microsoft page:
Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install("C:\SWSETUP\Adobe\GR\Adobe Reader 6.0.1
- Deutsch.msi", , ALL_USERS)
But nothing happens when I call this script! I also tried to use:
"C:\SWSETUP\Adobe\GR\Adobe~1.msi"
(My error code is here: 2)
I really want the application only to start after Adobe Reader 7.0 was
installed successfully. There should be almost no way to do something
wrong with this CD.
Any hints?
Another question would be: How can I know if the installation was
successful? I mean how to analyse the error code returned?
Thanks a lot again,
tanne
> Thanks a lot to both of you, with your help I figured it out!
>
> Maybe you could help me with another question:
> In the same script I want to start the installation of Adobe Reader.
> And I want the script to wait until the installation ends and then
> start
> another application/program.
>
> I already got it done by using the download exe-file from the adobe
> website: AdbeRdr70_deu_full.exe
>
> errCode = wShell.run("C:\AdbeRdr70_deu_full.exe",, TRUE)
>
> This works but unfortunately it just waits until this special
> application did run and then when the real setup starts (I can't
> access this setup directly) my script is not waiting anymore!
>
> (snip)
Hi,
It doesn't seem to be any way to let AdbeRdr70_deu_full.exe wait for
the installation to finish, you will need to get to the files inside
that exe file.
To obtain the files, you can do like this:
1.
Manually run AdbeRdr70_deu_full.exe, and when it has finished
extracted the files and launched the real MSI installation and
then removed itself from the task list, do the following:
2.
Just let the MSI installer dialog box be left alone (don't start
the "real" Acrobat Reader installation).
3.
Go to the folder C:\Program Files\Adobe\Acrobat 7.0\Setup Files\. In
some subfolder there you will find the file "Adobe Reader 7.0.msi"
and "Data1.cab" (there are some more files there as well).
4.
Copy those two files to your setup folder, e.g. C:\SWSETUP\Adobe\7.0\
(you might want to copy those other files as well, but I am pretty
sure they are not needed, but it doesn't hurt to include them).
5.
Cancel the Acrobat Reader installation, and delete the files/folders
in C:\Program Files\Adobe\Acrobat 7.0\Setup Files\
For a unattended installation of Acrobat Reader, you can now use this
command line (NB! the line will wrap over to lines in the newsgroup
post):
msiexec.exe /qb- /i "C:\SWSETUP\Adobe\7.0\Adobe Reader 7.0.msi" ALLUSERS=2
SETUPEXEDIR="C:\SWSETUP\Adobe\7.0" EULA_ACCEPT=YES REBOOT=ReallySuppress
I usually use this to get a unattended install with a progress bar
/qb-
If you have Windows Installer 2.0 installed, you can remove the Cancel
button by adding a !, like this:
/qb-!
A completely silent installation (no UI at all, no progress bar etc.):
/q as well as /qn
You can check the return value (errorlevel) from MsiExec.exe.
3010 means a successful installation that needs a reboot. 0 means a
success installation. So any other value than 0 and 3010 means an
error occurred during the installation
Now try the following VBScript (adjust path in sInstFolder if
necessary):
'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
sInstFolder = "C:\SWSETUP\Adobe\7.0"
sLaunchCmd = "msiexec.exe /qb- /i """ & sInstFolder _
& "\Adobe Reader 7.0.msi"" ALLUSERS=2 SETUPEXEDIR=""" _
& sInstFolder & """ EULA_ACCEPT=YES REBOOT=ReallySuppress"
MsgBox "Launch command:" & vbCrLf & vbCrLf & sLaunchCmd
iRetVal = oShell.Run(sLaunchCmd, 1, True)
If iRetVal = "3010" Then
MsgBox "Installation was successful, reboot needed"
Elseif iRetVal = "0" Then
MsgBox "Installation was successful"
Else
MsgBox "Installation was NOT successful, error code returned: " & iRetVal
End If
'--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx
>"Michael Bednarek" wrote in message news:mp29f1hh1tme97r6p...@4ax.com
>> >With CreateObject("WScript.Shell")
>> > MsgBox .Regread("HKCR\AcroExch.Document\AcrobatVersion\")
>> >End With
>>
>> Not in my registry (Acrobat 7 and Reader 7 installed). OTOH there are:
>> HKCR\AcroExch.App\AcrobatVersion
>> HKCR\AcroExch.FDFDoc\AcrobatVersion
>> HKCR\AcroExch.RMFFile\AcrobatVersion
>> HKCR\AcroExch.XDPDoc\AcrobatVersion
>> HKCR\AcroExch.XFDFDoc\AcrobatVersion
>> I don't know whether these would be present in an environment where only
>> the reader is installed.
>
>Well, doesn't this work?
>
>With CreateObject("WScript.Shell")
> MsgBox .RegRead("HKCR\" & .RegRead("HKCR\.pdf\") & "\AcrobatVersion\")
>End With
No, not here. I enumerated all occurrences of AcrobatVersion in my
registry in my previous post.
The only reliable method I found was to inspect the version information
in the executable itself, in the part of my post you snipped silently.
You can use the 'GetFileVersion' of the 'Scripting.FileSystemObject'
object:
Dim FSO, WSH
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSH = CreateObject("WScript.Shell")
Location = WSH.RegRead("HKLM\SOFTWARE\Microsoft\Windows\" &_
"CurrentVersion\App Paths\AcroRd32.exe\")
MsgBox FSO.GetFileVersion(Location)
nor does:
MsgBox .RegRead("HKCR\" & .RegRead("HKCR\.pdf\") & "\AcrobatVersion\")
Although I have the directory AcroExch.Document, I have no idea why it
is not working! Does one of you have?
The I tried the idea from James Whitlow by extracting the version from
the executable, this works.
(I would be prefer the first solution but unfortunately I don't know
how to fiy it.)
What I want to know from you, what is your opinion? Is there one better
or how can I say nicer then the other?
What is more professional and resistant against errors or different
versions! I now I have to test it with different
windows versions and acrobat versions but still any hint from you would
be appreciated!
> Sorry, it's me again. After I installed Acrobat 7.0 the version check I
> use before is not working anymore!
> MsgBox .Regread("HKCR\AcroExch.Docume要t\AcrobatVersion\")
>
> nor does:
> MsgBox .RegRead("HKCR\" & .RegRead("HKCR\.pdf\") & "\AcrobatVersion\")
>
> Although I have the directory AcroExch.Document, I have no idea why it
> is not working! Does one of you have?
>
> The I tried the idea from James Whitlow by extracting the version from
> the executable, this works.
> (I would be prefer the first solution but unfortunately I don't know
> how to fiy it.)
>
> What I want to know from you, what is your opinion? Is there one better
> or how can I say nicer then the other?
> What is more professional and resistant against errors or different
> versions! I now I have to test it with different
> windows versions and acrobat versions but still any hint from you would
> be appreciated!
>
Hi,
Here is what I would have used:
'--------------------8<----------------------
Set oFSO = CreateObject("Scripting.FileSystemObject")
sPathToAcroReadExe = RegRead("HKLM\SOFTWARE\Microsoft\Windows" _
& "\CurrentVersion\App Paths\AcroRd32.exe\")
SetLocale "en-us" ' do not remove
If sPathToAcroReadExe <> "" Then
sFullVersion = oFSO.GetFileVersion(sPathToAcroReadExe)
WScript.Echo "Full version number: " & sFullVersion
aFullVersion = Split(sFullVersion, ".")
vAcroReadVersion = CSng(aFullVersion(0) & "." & aFullVersion(1))
WScript.Echo "Major version number: " & vAcroReadVersion
Else
WScript.Echo "Acrobat Reader is not installed"
vAcroReadVersion = 0
End If
If vAcroReadVersion < 7.0 Then
WScript.Echo "Acrobat 7.0 or newer is not installed"
Else
WScript.Echo "Acrobat 7.0 or newer is installed"
End If
Function RegRead(sRegValue)
Set oShell = CreateObject("WScript.Shell")
On Error Resume Next
RegRead = oShell.RegRead(sRegValue)
' If the value does not exist, error is raised
If Err Then
RegRead = ""
Err.clear
End If
' If a value is present but uninitialized the RegRead method
' returns the input value in Win2k.
If VarType(RegRead) < vbArray Then
If RegRead = sRegValue Then
RegRead = ""
End If
End If
On Error Goto 0
End Function