Click here to Skip to main content
15,884,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!

I have wxs project file:

XML
<Product Id="$(var.ProductCode)" Name="$(var.ProductName)" Language="1049" Codepage="1251" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
    <Package InstallerVersion="200" Compressed="yes" AdminImage="yes" InstallScope="perMachine" />


...

Custom actions:

XML
<CustomAction Id="VSDCA_FolderForm_AllUsers" Property="FolderForm_AllUsers" Value="ALL" />
    <CustomAction Id="_3D169966_7F4D_439B_8537_BD70D91919BA" Execute="deferred" FileKey="_2EFFD1DC_7915_4BB8_9CBB_5EA8A904EBC3" adx:VSName="ProjService.exe" ExeCommand="-uninstall" />
    <CustomAction Id="_305A6029_72A4_489A_8231_A0220BE7101E" Execute="deferred" FileKey="_2EFFD1DC_7915_4BB8_9CBB_5EA8A904EBC3" adx:VSName="ProjService.exe" ExeCommand="-install" />
    <CustomAction Id="_59E2C944_6709_459D_9DBE_88945EBFA44C" Execute="deferred" FileKey="_A2D15616_D4F4_447A_B3D2_4F41E4696152" adx:VSName="CheckOs.dll Save parametrs" DllEntry="SaveParametrs" />
    <CustomAction Id="_59E2C944_6709_459D_9DBE_88945EBFA44C.SetProperty" Property="_59E2C944_6709_459D_9DBE_88945EBFA44C" Value="[TARGETDIR]|[SERVERSANDPORTS]" />
    <CustomAction Id="_AB08B803_44E2_49A9_9413_45FAB63CEA4D" Execute="deferred" FileKey="_A2D15616_D4F4_447A_B3D2_4F41E4696152" adx:VSName="CheckOs.dll Show warning messages" DllEntry="ShowWarningMessages" />
    <CustomAction Id="_1D5A2ADF_9073_427C_9E29_35D656BAC599" Execute="deferred" FileKey="_A2D15616_D4F4_447A_B3D2_4F41E4696152" adx:VSName="CheckOs.dll Check X64" DllEntry="CanInstall" />
    <CustomAction Id="_1D5A2ADF_9073_427C_9E29_35D656BAC599.SetProperty" Property="_1D5A2ADF_9073_427C_9E29_35D656BAC599" Value="[TARGETDIR]" />
    <CustomAction Id="DIRCA_TARGETDIR" Property="TARGETDIR" Value="[ProgramFilesFolder]ProjClient" Execute="firstSequence" />


And InstallExecuteSequence

XML
<InstallExecuteSequence>
      <Custom Action="DIRCA_TARGETDIR" Before="CostInitialize"><![CDATA[TARGETDIR = ""]]></Custom>
      <Custom Action="_1D5A2ADF_9073_427C_9E29_35D656BAC599.SetProperty" After="StartServices"><![CDATA[$comp_A0CCA35C_322E_4040_AD3F_AE7AB4382C73>2]]></Custom>
      <Custom Action="_1D5A2ADF_9073_427C_9E29_35D656BAC599" After="_1D5A2ADF_9073_427C_9E29_35D656BAC599.SetProperty"><![CDATA[$comp_A0CCA35C_322E_4040_AD3F_AE7AB4382C73>2]]></Custom>
      <Custom Action="_AB08B803_44E2_49A9_9413_45FAB63CEA4D" After="_1D5A2ADF_9073_427C_9E29_35D656BAC599"><![CDATA[$comp_A0CCA35C_322E_4040_AD3F_AE7AB4382C73>2]]></Custom>
      <Custom Action="_59E2C944_6709_459D_9DBE_88945EBFA44C.SetProperty" After="_AB08B803_44E2_49A9_9413_45FAB63CEA4D"><![CDATA[$comp_A0CCA35C_322E_4040_AD3F_AE7AB4382C73>2]]></Custom>
      <Custom Action="_59E2C944_6709_459D_9DBE_88945EBFA44C" After="_59E2C944_6709_459D_9DBE_88945EBFA44C.SetProperty"><![CDATA[$comp_A0CCA35C_322E_4040_AD3F_AE7AB4382C73>2]]></Custom>
      <Custom Action="_305A6029_72A4_489A_8231_A0220BE7101E" After="_59E2C944_6709_459D_9DBE_88945EBFA44C"><![CDATA[$comp_B2547267_A9C5_4B8B_AA20_4380CCF78AAD>2]]></Custom>
      <Custom Action="_3D169966_7F4D_439B_8537_BD70D91919BA" After="MsiUnpublishAssemblies"><![CDATA[$comp_B2547267_A9C5_4B8B_AA20_4380CCF78AAD=2]]></Custom>
    </InstallExecuteSequence>


My custom auction do CopyFile in Program Files directory.
I have UAC with maximum level. If I run my msi (UAC is showing), after the main directory in program files is created, but after my custom actions is called without admin rights and I can not copy additinal file to program files.
If I disable UAC then msi is work correctly and my custom action is run with admin right. How to fix?
Please help.
Thanks.
Posted

First question the Copy Custom action you have made is it deferred and impersonate = false ?

If no, on google you will find that only Custom Action deffered can have full right natively (because it's assume only deffered action can change your PC state/transaction and not Immediate action).

When you have the UAC prompt asking you to become privileged it will only make the client side privileged and not the server side of the msi (check the logs if you have enable it and use WiLogUtl.exe tools on it)

below link is a trick that will only work if you have an user interface create this custom Action it will ask for admin right for both side server and client.

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Custom-Actions-with-elevated-privledges-td5435239.html[^]

if (!hasAdministrativeRight)
{
if (MessageBox.Show("This installer requires administrator privileges.\r\n\r\nDo you want to attempt to restart it with administrator privileges?", "Administrator Privileges Required", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.Verb = "runas";
processInfo.FileName = "msiexec";
processInfo.Arguments = "/i " + session["OriginalDatabase"];
try
{
Process.Start(processInfo);
}
catch (Win32Exception)
{
//Do nothing. Probably the user canceled the UAC window
}
}
return ActionResult.UserExit;
}
 
Share this answer
 
Thank you, Fred!
I have decision. Thank you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900