I'm hoping someone can please help me out with some problems I'm having with running a Custom Action I've created. It's a simple VBScript to install a certificate, where the .cer file is installed to the INSTALLDIR directory.

Problem 1. Using the command str = Session.Property("INSTALLDIR"), I can obtain the installation directory, but only if I run the Custom Action with Immediate Execution. This doesn't work as InstallFiles only runs during Deferred Execution. I can see that the INSTALLDIR property is not set when running in Deferred Execution by using a MSGBOX to display str after it is set.

On a side note, if I put a MSGBOX into a second Custom Action and run one Immediate and one Deferred, the MSGBOX appears for the Deferred Custom Action first and then the Immediate Custom Action second. This seems to go against what you'd expect.

Problem 2. If (for testing) I put the .cer file in a 'known' location like C:\temp rather than use a variable, I can run the script successfully. However I've added a new Feature so that I can choose whether or not to install the shortcuts and add them after the program is already installed if required. With this new Feature I've set the install level to 101 so that it won't install by default and this will install successfully. I can then re-run the install using (msiexec /i ... ADDLOCAL=Feature) which again will install successfully adding the shortcuts. If however I try to clean install the program with the ADDLOCAL=Feature property set, then the install fails with the above Custom Action erroring. It appears that for some reason using the ADDLOCAL=Feature property causes the Custom Action to run either Immediate or earlier in the sequence and hence InstallFiles has not installed the files the VBScript requires to run. This isn't a problem if you're running the ADDLOCAL=Feature to update the install as the files already exist, but is a problem for a clean install.

Thanks for any advice you can provide to help me understand what is happening here.
Brett
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

1
1a. Why use a script to install a certificate? What's wrong with including the file with the package and having a CA run CertMgr.EXE against that file?

1b. The sequence order of execution is where you need to look. Remember that EI builds an internal script of actions to run, effectively, in ED. Check out the sequence in the InstallExecuteSequence table. I'll bet your EI CA is numbered after the ED one.

If you decide - for whatever reason - to continue with the scripted approach, you need to research you to use the special CustomActionData property. Essentially, in EI, you name a property with the name of the ED CA. You populate that property with the data you want to pass (in this case, INSTALLDIR). Then, in your CA, you need to access Session.Property("CustomActionData"). http://msdn.microsoft.com/en-us/library/aa370543%28VS.85%29.aspx

2. Either of the above approaches will probably fix this, since the file will be present by dint of its being installed.
Answered 10/15/2009 by: VBScab
Red Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Thanks so much VBScab, method 1a sorted it out the property issue. Thanks for the link as well, that made sense of why I couldn't access the INSTALLDIR property in ED.

Unfortunately, it hasn't fixed problem 2. Again, I can run the installer msiexec /i ... /qb and it will install successfully. I can then run msiexec /i ... ADDLOCAL=Shortcuts /qb and it will successfully add the shortcuts. But if I clean install with msiexec /i ... ADDLOCAL=Shortcuts /qb my MSI will fail (checking the install directory at error time shows that the files have not yet been installed).

As we're using SCCM, I could just run the program twice, once to install, once to add the shortcuts, but that's pretty hacky. Any other thoughts?
Answered 10/15/2009 by: brettski
Purple Belt

Please log in to comment
1
Using ADDLOCAL, you must specify ALL the features you want to install. As ever, a verbose log of the install would show you which features are being installed in each scenario.
Answered 10/16/2009 by: VBScab
Red Belt

Please log in to comment
0
Thanks again VBScab. That was the cause of the problem.
Answered 10/20/2009 by: brettski
Purple Belt

Please log in to comment
Answer this question or Comment on this question for clarity