[wix-users] Permission to Stop/Start a Service from a Custom Action on Button click

Gerhard Matzen gmatzen at osisoft.com
Wed May 30 05:57:52 PDT 2018


It sounds like you are not running the MSI elevated. You can convince yourself by verifying the “IngegrityLevel” in Process Explorer from the SysInternals suite.

With user account control (UAC), being an administrator on the machine does not mean that all processes that you launch will be launched elevated.

From: Ven H <venh.123 at gmail.com>
Sent: Wednesday, May 30, 2018 5:28 AM
To: Gerhard Matzen <gmatzen at osisoft.com>
Cc: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
Subject: Re: [wix-users] Permission to Stop/Start a Service from a Custom Action on Button click

Thanks a lot. I am already an Administrator. That's why I am confused, as to why it is not working.

Regards,
Venkatesh

On Wed, May 30, 2018 at 5:51 PM, Gerhard Matzen <gmatzen at osisoft.com<mailto:gmatzen at osisoft.com>> wrote:
You can make sure the user is privileged in a launch condition for the MSI.

<Condition Message="You must run this installation kit as administrator.  If you are running on Vista/Server 2008 or greater, you must also run the installation from an elevated command prompt.">Privileged</Condition>

If you are worried about the "Programs and Features" Change/Modify button not launching your MSI elevated, you should be able to set the NoElevateOnModify value in the registry.
This DWORD goes under:
"Software\Microsoft\Windows\CurrentVersion\Uninstall\YouAppName"


-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org<mailto:wix-users-bounces at lists.wixtoolset.org>> On Behalf Of Ven H via wix-users
Sent: Wednesday, May 30, 2018 4:07 AM
To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org<mailto:wix-users at lists.wixtoolset.org>>
Cc: Ven H <venh.123 at gmail.com<mailto:venh.123 at gmail.com>>
Subject: [wix-users] Permission to Stop/Start a Service from a Custom Action on Button click

I have a Custom Action that is called on a button click. In this button click, I have to restart the Sql Service on the local machine. After building this msi, if I right click and install, it fails while trying to Stop & Start the service using ServiceController class (throws an access denied exception). I tried with the WMI approach also, but the same result.

 But if I open up a PowerShell or Console window as Administrator and execute the msi using msiexec command, it works fine. I am already an administrator in the machine. I am not able to understand why it doesn't work in the first case, whereas it works in the second case, even though I am admin. How can I ensure in my Custom Action code to behave like the second case?

I tried with and without Impersonate attributes on the Custom Action, but no luck. Since it is called on button click, I am not able to make the CA deferred and hence it is immediate. In my CA code, when I check the current user using Environment.GetEnvironmentVariable("USERNAME") and also using System.Security.Principal.WindowsIdentity.GetCurrent(), it shows the same in both the cases. I am a little confused. Can anyone please help me?
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant https://urldefense.proofpoint.com/v2/url?u=http-3A__www.firegiant.com_&d=DwICAg&c=rxxrGm2iek7pTJSSe1mAiw&r=8MUQEKTKe_mBRfow6NKhbaPfXB9hL3W80bUJJehenQg&m=7jX_Lv6a4BSknM5oq_ZBaIoZMunArGzbAGk3wLYx2kg&s=lYzG1l7Ev3LfBTMXMy4Zfj7WaYfCV0f3OJ9Kd9Cm8_Y&e=



More information about the wix-users mailing list