cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ahning
Level 2

Launch application as Administrator in Windows Vista

Hi all,

I am currently building an installation package. During the installation process, I need to launch an application with parameteres. Currently I am using the following lines to run the application:

if (LaunchApp("Iam.exe", "-a -b -c") < 0) then
MessageBox ("Unable to launch App.",SEVERE);
endif;

The application needs to run as administrator in Windows Vista in order to work properly. I have already set "Required Execution Level" to "Administrator" for the Setup.exe. There is no error during installation, but this application is not function correctly.

This is quite urgent. Any help is appreciated. Thanks in advance.

Richard
Labels (1)
0 Kudos
(4) Replies
Kelter
Level 10

I'd recommend using LaunchAppAndWait() or LaunchApplication(). Calling LaunchApp will launch the specified application, and continue execution, which doesn't really give you a chance to check the return code of the app, or anything.

From the InstallScript Help Library:
If the application cannot be launched, the LAAW_PARAMETERS system variable’s nLaunchResult member contains the result of calling the Windows API function GetLastError after the CreateProcess or ShellExecuteEx call. If the function is successful and the LAAW_OPTION_WAIT option was specified, the LAAW_PARAMETERS system variable’s nLaunchResult member contains the return code of the launched application.


...so if LaunchApplication() with the parameter LAAW_OPTION_WAIT returns <0, then you can print out a debugging message with the return value of the launched app, "LAAW_PARAMETERS.nLaunchResult."

Hope that helps.

M<
0 Kudos
ahning
Level 2

Actually I used function LaunchAppAndWait() first. But there won't be any error message. The application can be executed. But it won't work if executed as per normal. It works only when executed as administrator. That's the tricky part.:(
0 Kudos
Holger_G
Level 10

You can launch the executable by using the ShellExecuteEx Windows API with 'runas' for the lpVerb variable. Works for me.
0 Kudos
Kelter
Level 10

Additionally, any CA that requires Administrative Privs should be run "Deferred in system Context." I've had the same problem with a dll call.
0 Kudos