DrJones
Posts: 18
Joined: Wed Jun 28, 2006 10:00 pm

Custom action (exe) with admin rights

Our installer runs two applications that are installers for other programs bundled with ours.

Those installers (made with a separate program) don't run in Vista unless our setup file is run with the "run as administrator" option.

We have the two .exes set up as UI Custom Actions that are run after our files are installed.

Is there a way to execute these custom actions with the "run as administrator" option (or something that will have the same effect)?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom action (exe) with admin rights

Hi,

For what you need you can try one of these approaches:

1) Use "Launch file as Administrator" UI custom actions for a "Next" button on a custom dialog.
2) Use an EXE bootstrapper which requires an execution level. To enable the EXE bootstrapper you can use the Bootstrapper tab of the "Media" page. In the same tab you can set the "Execution Level" combo box to "Require Administrator".

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Custom action (exe) with admin rights

DrJones wrote:Our installer runs two applications that are installers for other programs bundled with ours.
Hello DrJones,

are these two Windows Installer packages? As far as I know only one Windows Installer package can be executed/installed at the same time.
Is there a way to execute these custom actions with the "run as administrator" option (or something that will have the same effect)?
You can set the execution level of any .exe file by changing it's embedded manifest or by placing a "myfile.exe.manifest" (for a file called "myfile.exe") with a respective manifest.

We use this basic manifest usually:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
	<assemblyIdentity
		version="1.0.0.0"
		processorArchitecture="X86"
		name="TeamDrive"
		type="win32">
	</assemblyIdentity>
	<description>TeamDrive</description>
	<dependency>
		<dependentAssembly>
			<assemblyIdentity
				type="win32"
				name="Microsoft.Windows.Common-Controls"
				version="6.0.0.0"
				processorArchitecture="X86"
				publicKeyToken="6595b64144ccf1df"
				language="*">
			</assemblyIdentity>
		</dependentAssembly>
	</dependency>

	<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
		<security>
			<requestedPrivileges>
			<requestedExecutionLevel
				level="RequireAdministrator"
				uiAccess="false"/>
			</requestedPrivileges>
		</security>
	</trustInfo>

</assembly>
Depending on the requirements you may have to temper with uiAccess and others, too. (You should probably first extract the manifest (mt.exe) from the exe files and just add the necessary bits to ensure nothing is missing or configured incorrectly.)

One problem with flagging the exe files like that is that the elevation prompt usually ends up in the background/blinking on the task bar. So unless the user notices that (have enough items on the task bar and then you won't), he'll sit there thinking "Well? Does it proceed or not?". (That's when he'll seriously consider the "cancel" button on currently displaying installer page...)



With best regards

Clemens Anhuth

Return to “Common Problems”