Solved

Adobe Execute Problem

Posted on 2004-10-04
10
393 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now