cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mumbles
Level 7

LaunchAppandWait Windows 7 Custom Action.

Ok my last thread was bust.

This is a much simpler question.

I'm running a custom action with:

LaunchAppAndWait(C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe, PathToOurDll, wait, minimized)

On Windows 7, this doesn't execute. I've tried to set it to Deferred Action in the system context as suggested. But it still doesn't work.

Is anyone getting this to work?
Labels (1)
0 Kudos
9 Replies
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

To debug this issue, what is the return value from LaunchAppAndWait? If it is not zero, what is the value contained in LAAW_PARAMETERS.nLaunchResult? This will provide a Win32 error indicating why the exe did not launch. (Note that if LaunchAppAndWait returned zero, this value will be set to the return code of the launched executable once it has exited.)
0 Kudos
mumbles
Level 7

It doesn't fail. It doesn't return 0.

For reference, i created a setup.exe and right clicked as administrator, instead of using our MSI and it worked...

I think it's purely a rights thing.

But we want to use an MSI and in windows 7, we lost the Right Click on MSI and get 'Run as Administrator' shield thing.

Can i get back the shield to run my msi? or should i be running my custom actions differently?
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

If LaunchAppAndWait successfully launches the executable when run as administrator, this would imply that elevated privileges are necessary to launch this executable.

What is the value of LAAW_PARAMETERS.nLaunchResult after LaunchAppAndWait returns and the exe wasn't launched?
0 Kudos
mumbles
Level 7

joshstechnij wrote:
If LaunchAppAndWait successfully launches the executable when run as administrator, this would imply that elevated privileges are necessary to launch this executable.

What is the value of LAAW_PARAMETERS.nLaunchResult after LaunchAppAndWait returns and the exe wasn't launched?


nResult = LaunchAppAndWait(CMD, "/c" + szApp, LAAW_OPTION_WAIT|LAAW_OPTION_MINIMIZED);

where szApp is as in the above post. It just runs through. I even set it to check exit code, nothing. Just keeps going as if it worked.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

I apologize for any misunderstanding, but the code provided does not read the value of LAAW_PARAMETERS.nLaunchResult. Please try adding a line similar to the following after the LaunchAppAndWait call:

SprintfBox(0, "test", "launch result: %d", LAAW_PARAMETERS.nLaunchResult);


What does the message box display when the exe fails to launch?

Note that if you are launching cmd.exe, you may want to replace /c with /k so that the command prompt stays open after the batch or command file passed to it has exited. This will at least allow for viewing any errors that occurred.
0 Kudos
mumbles
Level 7

joshstechnij wrote:
I apologize for any misunderstanding, but the code provided does not read the value of LAAW_PARAMETERS.nLaunchResult. Please try adding a line similar to the following after the LaunchAppAndWait call:

SprintfBox(0, "test", "launch result: %d", LAAW_PARAMETERS.nLaunchResult);


What does the message box display when the exe fails to launch?

Note that if you are launching cmd.exe, you may want to replace /c with /k so that the command prompt stays open after the batch or command file passed to it has exited. This will at least allow for viewing any errors that occurred.


I'll try that right now. But speaking of using cmd.exe, is this even the preferred way to do such an action? Or should i be calling regasm.exe directly?
0 Kudos
mumbles
Level 7

RegAsm : error RA0000 : An error occurred while writing the registration information to the registry. You must have administrative
credentials to perform this task. Contact your system administrator for assistance

And the box states: launchresult -1073741510

So here's the thing. I knew this was the reason it wouldn't complete... so my beef isn't with getting launchappandwait to work.

It's more about what do i need to do to get my custom action to run with elevated privileges.

Now, i've set my packge 'RequireAdministrativePrivileges' = yes. I've tried running this custom action with;

1. Deferred Execution
2. Deferrred Execution int he system context.

Neither works. However, when i create a setup.exe and right click as administrator it all works.

What am i missing in the MSI scenario?
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Regasm.exe should be launched directly instead of through cmd.exe.

Assuming that this action depends on a file installed with the product, sequencing your custom action after InstallFiles with an in-script execution setting of "deferred in system context" should run the action late enough that the files it needs are installed, and it should run with elevated privileges Note that for deferred in system context actions to run elevated, the package being installed needs to be installed per-machine (ALLUSERS=1). Setup.exe should not be required for system context actions to run elevated.
0 Kudos
mumbles
Level 7

joshstechnij wrote:
Regasm.exe should be launched directly instead of through cmd.exe.

Assuming that this action depends on a file installed with the product, sequencing your custom action after InstallFiles with an in-script execution setting of "deferred in system context" should run the action late enough that the files it needs are installed, and it should run with elevated privileges Note that for deferred in system context actions to run elevated, the package being installed needs to be installed per-machine (ALLUSERS=1). Setup.exe should not be required for system context actions to run elevated.


Yes, it does depend on files installed with product.

Interesting, ALLUSERS=1 and i do run that after installfiles. Alas, i'm calling cmd.exe and not regasm.exe directly though.

My file is installed, it just never registers with regasm.exe. That's the ultimate problem.

Since several people in here are essentially having the same problem, is it possible to attach an example basic MSI project, which calls regasm.exe and runs on Vista and Windows 7? Maybe it's just a matter of people finding different way's to cure the problem and we don't know what the right way to do it is...

Any chance?
0 Kudos