Solved

Adobe Execute Problem

Posted on 2004-10-04
10
396 Views
Last Modified: 2013-12-18
Hi

I need the code which would pick up the correct version of Adobe that the user has installed and then execute accordingly, at present all that i can do is hard code.

Any ideas, the following code is from the button.


@Command( [Execute]; "C:\\Program Files\\Adobe\\Acrobat 5.0
\\Reader\\AcroRd32.exe"; "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf" )


Thanks
0
Comment
Question by:DavidAbbott
[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
  • 5
  • 4
10 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12218622
Use this command to find the exe that is assocuiated with recent version of acrobat

@regQueryValue("HKEY_CLASSES_ROOT"; "AcroExch.Document\\shell\\open";"command")

This will return the exe file path

~Hemanth
0
 

Author Comment

by:DavidAbbott
ID: 12224641
Thanks for the reply would the code be something like this?

@Command( [Execute]; @regQueryValue("HKEY_CLASSES_ROOT"; "AcroExch.Document\\shell\\open";"command")
; "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf" )
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12226744
yes.. but before that check the registry value is not null !!

eg;
pdfExec := @regQueryValue("HKEY_CLASSES_ROOT"; "AcroExch.Document\\shell\\open";"command");
@if( pdfExec = ""; @Prompt([ok];"Error";"No executable found to launch the file !"); @Command( [Execute]; pdfExec ; "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf" ) )
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:qwaletee
ID: 12228546
Not quite.  The registry query will return something like:
"C:\Program Files\Adobe\Acrobat 6.0\Reader" "%1"

So, you need to pull off the first string as the executable name: "C:\Program Files\Adobe\Acrobat 6.0\Reader"
And, you should dorp the quotes: C:\Program Files\Adobe\Acrobat\Reader

What might work better for you is querying HKCR Software\Adobe\Acrobat\Exe
...which is Ibelieve what Adobe recommends!
0
 

Author Comment

by:DavidAbbott
ID: 12246306
Ok, thanks for the help, but am even more confused now
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12250663
why ?

You have to choose appropriate key that is it
0
 

Author Comment

by:DavidAbbott
ID: 12251001
the error message keeps being returned!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12251553
What is the error msg ?
0
 

Author Comment

by:DavidAbbott
ID: 12251580
"No executable found to launch the file !"
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 500 total points
ID: 12252023
Looks like that function can read only name value pair... and cannot read (Default) entries...

Only option left out is win32 API call..

Copy this into a ScripLibrary and use shell to execute your attachment

'OPTIONS SECTION
Option Public
Option Declare
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const ERROR_SUCCESS = 0&


' DECLARATIONS SECTION
Declare Function RegOpenKey Lib "advapi32" Alias "RegOpenKeyA" (Byval hKey As Long, Byval lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32" (Byval hKey As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" _
(Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, Byval lpData As String, lpcbData As Long) As Long


Function GetRegistryValue(hkey,SubKey As String,ValueName As String)
      Dim phkResult As Long, lResult As Long
      
      Dim tmppath$,filename$,path$
      Dim buflen As Long
      Dim valuetype As Long
      Dim key$
      
      lResult=RegOpenKey(hKey, SubKey, phkResult)
      If lResult<>ERROR_SUCCESS Then
            Messagebox "Error opening registry..."
            Exit Function
      End If
      tmppath$ = String(256, " ")
      buflen = Len(tmppath$)
      valuetype=1
      lResult = RegQueryValueEx(phkResult, ValueName, 0, valuetype, tmppath$, buflen)
      If lResult<>ERROR_SUCCESS Then
            Messagebox "Error getting value..."
            RegCloseKey phkResult
            Exit Function
      End If
      RegCloseKey phkResult
      GetRegistryValue=Left$(tmppath$, buflen-1)
End Function



USING THIS LIBRARY
=============

Include this into your form or agent..

second, use this to extract key value and execute file
      FilePath = "r:\\SPARE PARTS\\PROTECTION PRODUCTS.pdf"
      adobePath = GetRegistryValue(HKEY_CLASSES_ROOT, "Software\Adobe\Acrobat\Exe", "")
      If adobePath <> "" Then
            tast% = Shell(adobePath + " " + FilePath )
      End If
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

710 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