Solved

Custom action UI handler/managed code example to launch exe and handle errors other than 0

Posted on 2013-06-21
8
661 Views
Last Modified: 2013-06-28
Hi.
I am creating an MSI using InstallShield 2012 (part of AdminStudio).

The file structure I need installed on the PCs requires Adobe AIR, so I have created custom actions to silently install and uninstall Adobe AIR, and have sequenced these correctly in the Install Exec sequence. (I have the correct distribution license from Adobe)

The problem comes when I want to check (prior to the Adobe AIR installation / uninstall) whether or not AIR is already installed. I am using the Adobe ARH utility - which returns a non-zero value when Adobe AIR is not detected.
(http://airdownload.adobe.com/air/distribution/latest/win/arh.exe)

I am not a programmer; can anyone design (or point me towards) a managed code sample, or custom dll (or another way) that I can use to be able to correctly handle a non-zero return value from the Adobe ARH utility?

Essentially, install sequence is:
1) Copy files (MSI handles this bit)
2) Run ARH utility as part of a Custom Action to detect installed AIR (terminates with zero if a version is found installed, non-zero otherwise)
3) If previous CA terminated with non-zero value, run next CA (to install Adobe AIR)

uninstall sequence:
1) Run CA to uninstall Adobe AIR
2)Remove Files

(uninstall is fine as it is)

Can anyone give me any pointers, or sample code etc. to execute the ARH utility?
Alternatively, a better way to do this - i.e. Managed code or a custom dll?

TIA.
Andrew.
0
Comment
Question by:and235100
  • 4
  • 4
8 Comments
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39267444
Before we get to the custom action analyzing return code, here's indeed the alternative way. To detect if Air is already installed, find out some registry key that tells that it's installed, and create system search looking for that key. For instance, as I can see, there is a key HKEY_CLASSES_ROOT\Applications\ADOBEA~1.EXE\shell\open\command. Then use the result of that system search as a condition of the installation.

But if you really want to run the utility*, you probably need to run custom action type 2 . Incidentally, this custom action is indeed looking for return code 0 as success, so it should work for you. This is still not very good way, since if utility returns non-zero code, the installation will be canceled without telling the real reason. For a better handling, I would write vbscript that would launch the utility, then, depending on the return code, create a registry key. Then system search would look for that registry key as a condition of the installation. This would allow to specify the message to the user.


*) The desire to run the utility instead of looking at the registry key might be based on the belief that Adobe-supplied utility would detect Air in some very reliable way. Given that it's Adobe, it's unlikely. This is based on my personal experience, however the close look on the registry key I specified above, is already an illustration of it.
0
 
LVL 32

Author Comment

by:and235100
ID: 39268496
Thank you for your comments. Perhaps checking a condition based on a present registry key is a better way of doing this - but in my experience with several Adobe products, registry keys get left behind, and may result in a false positive.

I take your point regarding the reliability of an Adobe utility - but I would have thought (from my testing so far) that it is fairly reliable at detecting a version of Adobe AIR that is installed. (After all, that it is one of only 5-6 functions it actually is capable of doing! :-) )

What I am really trying to avoid within the msi install is a 1722 error - i.e. when the custom action using the ARH utility returns a non-zero value. ( I could choose to ignore the error code, but that isn't particularly satisfactory either)

Can you give me an example of some vbscript that would work?
Thanks again.
0
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 500 total points
ID: 39268552
>Can you give me an example of some vbscript that would work?

set v = createobject("wscript.shell")
rc = v.run("path\program.exe",,True)
if rc=0 then v.regwrite "HKCR\SOFTWARE\myinstallation\returncode",0


The description of the method "run" is at http://msdn.microsoft.com/en-us/library/d5fk67ky%28v=vs.84%29.aspx , and 3nd parameter True ensures wait on return and return code passed back to the script.

The main challenge is in placing arh.exe in place. This custom action has to run before the actual installation, which means that even if the installation installed arh.exe, it would be much later. Which means that arh.exe must be put in place by the custom action itself. I would access the current installation using Session object, access table Binary where I stored arh.exe, and stored it to %temp%. Writing such a code is not very trivial.

I have to warn, however, that although I personally have been using vbscript custom actions without a problem, some developers think it's dangerous (I would argue that (1) writing bad code is possible in vbscript as well as in dll, (2) developer's difficulties don't mean the result code is bad, and (3) antivirus can react on the custom dll as well as on the vbscript).
0
 
LVL 32

Author Comment

by:and235100
ID: 39268955
Thanks.

I will give this a go.

Is there not a way I can do this without a registry key? As you suggested, with a custom DLL or a small custom exe?

The point being, I should think I can run this after InstallFiles within the sequence, but use a custom exe or wrapper to call the ARH utility. The problem being, there is no error handling from the running of custom actions.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39269438
> The point being, I should think I can run this after InstallFiles

My whole point was that you want to run this check as install condition, but now that I re-read it, I was probably wrong. Writing to the registry key was part of that idea - you can then create install condition based on the system search for the registry key.

If you are going to run it after InstallFiles, then it's even easier: you can make arh.exe part of the installation, and then run it from installed files, no need to extract it from binary table. But then it would be deferred custom action, to which you would have to pass the INSTALLDIR via CustomActionData property.

Or there can be another way. If arh.exe gets installed along with Adobe Air, such as it is with Adobe Reader, as I can see on my own computer, then you can perform system search for Adobe Air, and run arh.exe from there.

That said, are you sure you even need all this. Even if Air is already installed, you can simply run its installation unconditionally, such as in repair mode, and if it's already in place, the (nested) installation will do nothing at all and won't take much time.
0
 
LVL 32

Author Comment

by:and235100
ID: 39270902
That is a very good point you make.
For reference, arh.exe doesn't seem to get installed with Adobe AIR)

Unfortunately, there do not seem to be any "repair" options for installing Adobe AIR. (according to http://help.adobe.com/en_US/air/redist/WS485a42d56cd19641-70d979a8124ef20a34b-8000.html#WS485a42d56cd19641-70d979a8124ef20a34b-7ffb) (not a problem, however, as we only add a couple of registry keys in to prevent updates etc.)

The problem is, I cannot handle errors natively, so I will have to ignore the return code, include the registry, and "hope" that an error doesn't occur.

I am already running the ARH utility deferred in system context - which is fine - but I cannot handle any non-zero value that it returns.

Perhaps I am making this too complicated - but there must be a way to "wrap" the arh.exe utility and catch the error. This is by far the best way of checking that Adobe AIR is installed, in my opinion - because it will detect current and future versions.

If I include the Adobe AIR install in my msi - I would have to update this everytime a new version of AIR was released - not particularly satisfactory in my opinion.

Thanks again.
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39273358
> Unfortunately, there do not seem to be any "repair" options for installing Adobe AIR.

Simply run msiexec /qn /i setup.msi . If it's already installed, it will do nothing; if not, it will install. I'm sure, if older version found, it will upgrade. Exactly what you need.

That is, assuming you use AIR_win_installer_files.zip from the distribution3 page.
0
 
LVL 32

Author Comment

by:and235100
ID: 39285448
All good suggestions. Thanks for your help.
0

Featured Post

Don't lose your head updating email signatures!

Do your end users still have the wrong email signature? Do email signature updates bore you or fill you with a sense of dread? You can make this a whole lot easier on yourself by trusting an Exclaimer email signature management solution. Over 50 million users do...so should you!

Join & Write a Comment

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

18 Experts available now in Live!

Get 1:1 Help Now