cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gzvinstall
Level 4

How to set an executable property to 'Run as Administrator'?

I have an InstallScript MSI project.

On Windows Server 2008, there is a check box in the executable properties dialog to run it as an administrator.

Is there a way to do this from Install Script so that the user does not have to do this?

Thanks!
Labels (1)
0 Kudos

(9) Replies
esiemiat
Level 9

I don't know of a way to do this in InstallShield. We create a manifest file and name it the same as the exe file we are trying to force Run as Admin on. For example for a file named APP.EXE the manifest would be named APP.EXE.MANIFEST. This file is placed in the same folder as the EXE and contains the following XML code that instructs Windows how to handle the file.












0 Kudos
LKM_N4EN
Level 6

We can use the manifest file for exe, but how about if I want to call a function from dll? In Vista, it is required to run as administrator as the function need to access the registry.
0 Kudos
DLee65
Level 13

Is this a DLL that you compile in house? IF so why not have Visual Studio create and embed the manifest file for you? In VS2005 I just open the project, right click on the project in the Solution Explorer view, choose properties and then modify the manifest properties.
0 Kudos
gzvinstall
Level 4

I did update the manifests (wherever I could) of all our executables.

But for some, the build server won't let me do it. So, I was wondering for such exes, if I could do it from the install.

Any suggestions will be much appreciated.

Thanks!
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

If your calling code is running as a normal user, you can launch .exe files as administrator (subject to a UAC prompt) by using a call to the Windows API ShellExecute or ShellExecuteEx with a verb of "runas". Note that the InstallScript function LaunchApplication can use ShellExecute/Ex when passed the correct flags.

However a .dll file is invoked with the privileges of the calling application, so in this scenario there is no easy way to elevate. If you can wrap the .dll with a .exe you can turn it into the first scenario. If it's registered as a COM server, there are ways to do elevated COM invocations (but I've not studied them, especially from InstallScript). So the .dll case is probably a non-starter.
0 Kudos
gzvinstall
Level 4

For those executables that are to be run during the time of install, I used ShellExecute API and it works.

But this particular exe, the user can run it whenever he wants to. Is there a way to simulate the effect of manifest from the Install?

Thanks!
0 Kudos
VVorontsov
Level 2

Hi,

I have similar problem with DLL.

I need to install PnP and not PnP drivers. For this purpose I've modify "devcon.exe" (driver installation from command line utility - SetupAPI) to be a DLL and use it from IS merge module. It worked fine in 2000 and XP, but does not work in Vista. I guess it needs more rights to modify registry even if I run as administrator.

How to elevate privilege for DLL used from merge module?

Any help appreciated.
0 Kudos
IS2008_user
Level 2

Is there any commands in install scripts to set 'Run as Administrator'? flag to TRUE

I created teh manifest file. But I dont knwo how to embed it in the application exe I have. Pls help
0 Kudos
esiemiat
Level 9

You only have to install the manifest to the same folder as the EXE, Windows handles the rest. Just be sure to name the manifest correctly. Use the format Filename.exe.manifest.
0 Kudos