views:

1438

answers:

2

Environment: Install Shield 2009 Premier, Vista (Home/Premium, Ultimate)

I have a custom action in Install Shield 2009 that would fire during installation. If setup.exe is run its fine, but when run the MyApplication.msi in Vista(please note in other OS the custom actions work just fine) it shows exception running the custom action. Custom action is just executing an exe with command line arguments.

That exe executes just fine individually in that OS. But when MyApplication.msi wants to run it, it shows an exception.

I think: MyApplication.msi can't give that custom action(.exe file) proper privilege(administrative) to run with. But setup.exe can.

How can it be solved...?

Thanks, Samir

+1  A: 

You didn't state, but it sounds like your setup.exe has a manifest that requires administrative privileges (if you get a UAC prompt when you launch setup.exe, this is the case). It also sounds likely that the exe you are trying to run from your custom action has a similar administrative privileges requirement. An exe custom action in MSI uses CreateProcess which cannot elevate.

If your action runs in the UI sequence, you need to use ShellExecute or ShellExecuteEx somehow - this can be done with an InstallScript custom action using LaunchApplication with the flag LAAW_OPTION_USE_SHELLEXECUTE, or with C++ that calls ShellExecuteEx directly.

If your action runs in the Execute sequence, you should mark it "Deferred in System Context" so it is launched from an elevated context to begin with. This is generally preferred (at least in terms of user experience) as it avoids the extra UAC prompt that the other method will show. However any deferred action has limitations (such as minimal property access) you may need to familiarize yourself with.

Michael Urman
Samir
Ah, that's another limitation of deferred actions: they have to be scheduled between InstallInitialize and InstallFinalize. If you actually need it to be the first action, you'll probably need to fall back to the UI sequence method (which is doubly bad in the execute sequence, as the execute sequence is not supposed to show UI).
Michael Urman
Thanks a lot Micheal. It works. I also have added manifest file for that custom action although without it works in vista.
Samir
A: 

Samir, Could you please provide more details on how you have solved the issue?

From the Custom Action wizard for my custom action, for "In-Script Execution" value I chose "Deferred Execution In System Context"
Samir