Can you launch a non-elevated application from a perMachine WiX package? - wix

We have a per-machine install package built with WiX 3.9.
<Package InstallerVersion="405" Compressed="yes" InstallScope="perMachine" />
And we are also using WixShellExec to launch an application from a CustomAction as part of the package install.
<Property Id="WixShellExecTarget" Value="[#Application.exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="LaunchApplication" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
This launches our application as expected, but it launches the application with elevated permissions.
From what we have seen, it is not possible to launch the application without elevated permissions from a per-machine install package. We have tried various combinations of Impersonate="yes|no" and Execute="deferred|immediate". We have also tried using a FileKey custom action directly to launch the application.
We are using a custom bootstrapper application and so cannot use the built-in WiX UI around this functionality. Is the only way to achieve a non-elevated launch of our application to do so manually from our custom bootstrapper application?

You could try this - it's from a reliable source:
http://blogs.msdn.com/b/oldnewthing/archive/2013/11/18/10468726.aspx

Related

How do you install VS Tools For Office Runtime from my WiX installer? I'm getting "waiting for another install to complete" deadlock

I'm writing an installer for my Office Outlook add-in using WiX. The add-in itself requires VS Tools For Office Runtime to be installed. So I thought to install it as a custom-action from within my own WiX installer:
<Binary Id='idBinVstorRedist' SourceFile='Sources\vstor_redist.exe' />
<CustomAction Id="idCSVstorRedist" Return="asyncWait" HideTarget="no" Execute="deferred" Impersonate="no" ExeCommand="" BinaryKey="idBinVstorRedist" />
<InstallExecuteSequence>
<Custom Action="idCSVstorRedist" After="InstallInitialize">
NOT Installed
</Custom>
</InstallExecuteSequence>
where the vstor_redist.exe itself is part of my MSI package:
But when I run my installer it deadlocks in the VstorRedist with the message: "Waiting for another install to complete":
What am I doing wrong here?
To check whether the VSTO Office Runtime is installed, we’ll add condition and two RegistrySearch elements. RegistrySearch, does exactly what the name implies, it searches the target machines’ registry for a specific key and value.
<Property Id="VSTORUNTIMEREDIST">
<RegistrySearch
Id="VSTORuntimeRedist"
Root="HKLM"
Key="SOFTWARE\Microsoft\VSTO Runtime Setup\v4R"
Name="Version"
Type="raw" />
</Property>
<Condition
Message="The Visual Studio 2010 Tools for Office Runtime is not installed.
Please download and install from
http://www.microsoft.com/en-us/download/details.aspx?id=20479.">
<![CDATA[Installed OR VSTORUNTIMEREDIST>="10.0.30319"]]>
</Condition>
Read more about that in the Creating WiX installation projects for VSTO-based Office add-ins article.
Also, you may find the How do you use WiX to deploy VSTO 3.0 addins? article helpful.
It may be due to the fact that your custom action is set to run After="InstallInitialize". I'm trialing running a batch script to install the runtime after checking if it isn't present or not and it appears to be working okay for me like this
<InstallExecuteSequence>
<Custom Action="RunBatch" Before="InstallFinalize"/>
</InstallExecuteSequence>
<CustomAction Id="RunBatch"
Execute="deferred"
Return="ignore"
Impersonate="no"
ExeCommand=""[SystemFolder]cmd.exe" /C "[INSTALLFOLDER]vsto_runtime.bat""
Directory="INSTALLFOLDER"/>
This is not the recommended way to install prerequisites but after having issues with creating a bundle, this is a working short term fix for me
Hopefully this is of some use for you.

how to integrate third party installation along with current installer in wix?

I am trying to install visual c++ 2013 along with my installer in wix.
for that i am using custom installation like
<Binary Id="vcredist_x862013.exe" SourceFile="D:\Projects\vcredist_x862013.exe"/>
<CustomAction Id="Launchvc2013" BinaryKey="vcredist_x862013.exe" ExeCommand="" Execute='deferred' Return='asyncNoWait' Impersonate='no'/>
<InstallExecuteSequence>
<Custom Action='Launchvc2013' Before='InstallFinalize'>NOT Installed AND NOT REMOVE</Custom>
</InstallExecuteSequence>
currently if the user installs or didnt install vc2013 as part of installation the setup will continue.
is it possible to make it like, the set up should fail if user cancel visual c++ installtion?
Yes it possible, you need to use bootstrapper for that.
Use this blog by Heath Stewart to get you started.

prop.exe elevated execution in Wix

This question seems to have been answered ad nauseam on this web site but I cannot get Wix to run an exe with Administrator rights (Windows 8.1 64-bit).
The installer I develop copies the prop.exe utility (http://prop.codeplex.com/) to a folder under Program Files (appfolder) as well as a file (my_file.propdesc) which needs to be registered/unregistered by prop.exe like:
prop schema register my_file.propdesc (at the end of installation)
prop schema unregister my_file (at the beginning of uninstallation)
These two command lines need to be run with Administrator privileges. Because these should also be run without a command prompt, I've used CAQuietExec with another CustomAction preparing the argument for CAQuietExec (prop.exe is 32-bit so it's CAQuietExec instead of CAQuietExec64 if I am not mistaken).
<CustomAction Id='PropReg_Prep' Property='PropReg' Value='"[appfolder]prop.exe" schema register "[appfolder]my_file.propdesc"' Execute='immediate' />
<CustomAction Id='PropUnReg_Prep' Property='PropUnReg' Value='"[appfolder]prop.exe" schema unregister "[appfolder]my_file.propdesc"' Execute='immediate' />
<CustomAction Id="PropReg" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
<CustomAction Id="PropUnReg" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no" />
The custom actions are executed as per:
<InstallExecuteSequence>
<Custom Action="PropReg_Prep" After="CostFinalize" >NOT Installed</Custom>
<Custom Action="PropUnReg_Prep" After="CostFinalize" >Installed</Custom>
<Custom Action="PropUnReg" After="InstallInitialize" >Installed</Custom>
<Custom Action="PropReg" After="InstallFiles" >NOT Installed</Custom>
</InstallExecuteSequence>
I cannot get prop to register/unregister my_file.propdesc. Could someone help?
You are scheduling the actions as Execute='immediate' this runs as the user that executes the installer.
Switch to using Execute='deferred' this will run as the system account. Assuming that the prop.exe doesn't require a full profile to run this should work.
When you're not impersonating you're running with the system account, that's got admin privileges but if you are expecting it to be a user account then there might be issues.
The thing that looks weird to me is that [appfolder]prop.exe for a number of reasons. It doesn't look like a proper application folder, so make sure it's correct. It also needs to be in uppercase, making it a public property, and you should mark it Secure="yes" in the property element. The issue is that it may not get properly transferred from your immediate CA into the execute sequence where it's used.
p.s. Do the install creating a verbose log so you can see how those directory vales are actually being resolved at run time.

Elevated custom action before removing files

I'm trying to write an Installer for my Windows Service using WiX. My executable can register/unregister itself as a Windows Service using the command line parameters --install and --uninstall. This is what I came up with:
<CustomAction Id='InstallAsService' FileKey='CCWirelessServer.exe' ExeCommand='--install' Return='check' Impersonate='no' Execute='deferred' />
<CustomAction Id='InstallAsServiceRollback' FileKey='CCWirelessServer.exe' ExeCommand='--uninstall' Return='check' Impersonate='no' Execute='rollback' />
<CustomAction Id='UninstallAsService' FileKey='CCWirelessServer.exe' ExeCommand='--uninstall' Return='check' Impersonate='no' Execute='deferred' />
<InstallExecuteSequence>
<Custom Action='InstallAsService' After='InstallFiles' >NOT Installed</Custom>
<Custom Action='InstallAsServiceRollback' Before='InstallAsService' >NOT Installed</Custom>
<Custom Action='UninstallAsService' Before='RemoveFiles' >Installed</Custom>
</InstallExecuteSequence>
Both install and uninstall basically work. But during uninstall I get the following message:
The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.
Despite this error message, the service gets unregistered and the files are deleted without a reboot. To me this looks like the installer is checking if CCWirelessServer.exe is opened before it executes my custom action.
So my question is: How do I need to modify my install execute sequence so that this error message does no longer appear?
If you are developing for Windows Installer > 3.1 you can take a look at the MSIRESTARTMANAGERCONTROL-property to see if it it set properly or if other values would would stop displaying the message.
I could suppress the message using the following values:
<Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable" Secure="yes" />

Wix CustomAction to run only in basic mode

My wix 3.5 setup can be downloaded and run in normal installation situation. I also use the same msi for updates and call msiexec with /qb (basic quiet interface) from within the app itself.
All is ok up to here. In normal setups, I have an option to start app upon install (taken from tutorial) and works fine.
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Start $(var.AppName) $(var.ExeVersion) now..." />
<Property Id="WixShellExecTarget" Value="[#$(var.AppName).exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
I want my update to be quiet and start the updated app after successfull install. In order to do this I have a custom action like this in my InstallExecuteSequence:
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize"/>
<Custom Action="LaunchApplication"
After="RemoveExistingProducts"/>
</InstallExecuteSequence>
This is also ok too, however obviously, now my app is automatically started with normal (not /qb) setups. In order to overcome this, I suppose I need to detect in which UILevel I am and run the custom action only in INSTALLUILEVEL_BASIC.
So here is my question: How can I detect the UILevel in InstallExecuteSequence or CustomAction? Or is there a way to run CustomAction only in quiet basic mode in Wix.
You should condition condition the custom action by UILevel = 3