Executing a custom action that requires elevation after install

后端 未结 2 1334
别跟我提以往
别跟我提以往 2021-01-12 18:40

I have the following WiX snippet:




        
相关标签:
2条回答
  • 2021-01-12 19:01

    FYI, Immediate custom actions are ALWAYS impersonated (i.e. they always run as the user who executes the MSI).

    I like Michael Urman's idea regarding making your Configurator.exe handle the elevation issue.

    I wonder if you could also just include a manifest in your EXE so that the OS knows elevation is always required.

    0 讨论(0)
  • 2021-01-12 19:04

    The UI sequence is running as a limited user, and it launches applications with a call to CreateProcess. If you use something like a WixShellExec with [WixShellExecTarget] instead, it will act like Explorer and show a UAC prompt if the target requires elevation. Or you could modify your Configurator.exe to allow being launched without elevated privileges, detect that case, and relaunch itself with elevated privileges.

    For example, this should work:

    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
    <CustomAction Id="StartAppOnExit" BinaryKey="WixCA" DllEntry="WixShellExec" Execute="immediate" Return="check" Impersonate="yes"/>
    <Property Id="WixShellExecTarget" Value="[#Configurator.exe]"/>
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Configure initial settings" />
    <UI>
      <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="StartAppOnExit">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>
    
    0 讨论(0)
提交回复
热议问题