0

I have built a WIX project with custom WPF UI that must run with elevated privileges. After an install/update I want to start my application but I do not want the application to be started with Elevated privileges.

Currently I am doing the following

In "Protected Overrides Sub Run()" I do the following

Dim m_LowProcess As Process = Process.GetCurrentProcess

Then once the installer is finished I run the following code

        Dim procStartInfo As New ProcessStartInfo

            With procStartInfo
                .FileName = fInfo.FullName
                .WindowStyle = ProcessWindowStyle.Normal
            End With
            m_LowProcess.StartInfo = procStartInfo
            m_LowProcess.Start()

I have checked the process ID and Handle properties and they are identical. But my program still runs with a different privilege after an install.

What am I doing wrong or is this never going to work?

I am aware of this forum question which solves the problem other ways.

Community
  • 1
  • 1
darbid
  • 2,545
  • 23
  • 55

1 Answers1

0

I'm not sure what your code is doing, but I believe the correct way to do this is like this example in the ProcessStartinfo docs:

https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2

Just fire off the installed application by specifying the path to the executable and ensuring that UseShellExecute is true so that the process launch behaves like an explorer run (with no inheritance of privilege). If you don't know where the executable has been installed to, then a p/invoke to MsiGetComponentPath passing its component id and the product's product code will tell you: https://msdn.microsoft.com/en-us/library/aa370112(v=vs.85).aspx

PhilDW
  • 20,260
  • 1
  • 18
  • 28