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

"Run as Administrator"?

Project Type: InstallScript MSI

One of our installers is having issues with creating/configuring services in Windows 2008 Server. We launch several of our installed EXE files to register them as services. When we launch the apps via InstallScript the services get created but they do not carry the appropriate settings for our software to function. I've tried several methods of getting these services registered correctly from within InstallScript to no avail. I've tried calling the EXE files with LaunchAppAndWait(), ShellExecuteA() with "runas", including a .manifest file to elevate privileges and even launching a batch file to execute the EXE files. None of these has had the desired effect. The setup.exe is running with an embedded manifest level of "Administrator". And just for kicks I even ran setup.exe with a manifest file of its own. So far nothing has worked to elevate our three apps to administrator when creating the services. However, I can manually run each of them in an elevated command prompt after installation and that works perfectly, with or without manifest files.

Can anyone give me some explanation as to how to launch external apps (from InstallScript) with permissions elevated to administrator? I've looked all over and have not found a solution that works yet.
Labels (1)
0 Kudos
(14) Replies
ChandanOmkar
Level 8

Please Check the following link:

http://community.acresso.com/showthread.php?t=187635

hope this will help. Please let me know if you feel any problem.
0 Kudos
honolua
Level 7

We have kicked this idea around a bit. The only real drawback to this is that this executable serves multiple purposes. The /regserver switch we need to run it with at install time is the only part that requires the elevated administrative privileges. This executable ought to normally run as the invoker. But we may be forced to embed an administrator manifest if there is no other solution.
0 Kudos
honolua
Level 7

No other ideas on how to do this? I can't believe it has to be nearly impossible to execute an external app with administrative privilege without embedding a manifest file forcing the app to always run with elevated privileges.
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

Could you post your lines setting up and calling LaunchApplication? I'm quite certain I've successfully used the "runas" verb to elevate an exe that had an asInvoker manifest.
0 Kudos
honolua
Level 7

Below is my most current attempt. szLaunchStr is configured as the full path to the executable which I have verified is correct.

LAAW_SHELLEXECUTEVERB = "runas";
nResult = LaunchApplication( szLaunchStr, "/regserver", INSTALLDIR, SW_HIDE, 0, LAAW_OPTION_USE_SHELLEXECUTE );
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I'd mostly be concerned about the SW_HIDE option; the UAC prompt needs to show UI, and this may conflict. Can you tell if your process is launched (runs and fails) vs. is not launched (fails to run, might return ERROR_ELEVATION_REQUIRED = 740)?
0 Kudos
honolua
Level 7

The processes are being executed. I can see the services being created but something in their configuration isn't quite right (not sure what, though). When I run the software I get errors. If I then manually run the 3 apps in a "Run as Administrator" command prompt and restart the services the software functions correctly. I tried chaning out the SW_HIDE with SW_NORMAL and the results are exactly the same.
0 Kudos
honolua
Level 7

Any new thoughts on this? The number of external apps we need to run elevated jumped from three to five yesterday. So while my testing of the installer can continue it's becoming more urgent.
0 Kudos
TimStVCS
Level 7

Hello, you indicated that your project type is InstallScript MSI. Why not use the Self Register property for the .exe that you are installing to take the place of /regserver? Also, have you tried the Install NT Services in the Advanced Settings of the Components View to install your services and configure them? You may be able to avoid using InstallScript at all.

Just a thought!
0 Kudos
honolua
Level 7

Unfortunately, we have other things beyond creating services to consider, as well. We have a batch script that's used to create a local printer. This one also appears to require admin privileges in Server 2008 to actually create the printer. And it's very possible, likely even, we will have one or more other apps that need to run as administrator.
0 Kudos
honolua
Level 7

Can anyone suggest where my LaunchApplication is going awry? We still are not getting the proper elevation with the code I posted last week.
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

One other thought occurred to me; is it possible that either szLaunchStr is incorrect, or INSTALLDIR doesn't exist when this code is called? Perhaps put a MessageBox in with both, and verify they exist while the box is displayed.

The following test, which looks a lot like your code, seems to work fine for me.
LAAW_SHELLEXECUTEVERB = "runas";
LaunchApplication(WINDIR ^ "notepad.exe", "", WINDIR, SW_SHOW, 0, LAAW_OPTION_USE_SHELLEXECUTE);
0 Kudos
honolua
Level 7

Both szLaunchStr and INSTALLDIR are set and both are correct. Would it make any difference if the szLaunchStr contained a space such as "Program Files"? It doesn't seem to but I may not be seeing the whole picture here.
0 Kudos
honolua
Level 7

I believe the programs designated in szLaunchStr are in fact being executed but the privileges are not elevated high enough. We still have to manually execute our apps after the installation finishes in order to get our software to function.

We are also considering moving all of this functionality out of our regularly used programs and into a single install-time program with an embedded administrator manifest, at which point the privilege level when launched from IS becomes moot and our regularly used programs still run as invoker after install time.
0 Kudos