Note: The installer runs with admin rights on startup, it is a requirement for our installer that it always runs with admin rights and installs the application to program files folder
Note: The installer is build on visual studio 2019 setup project
I am developing an MSI, my requirement is to run the application (.exe) with admin rights, after the installation is finished (E.g user presses the finish button). I wrote a couple of C# custom actions which basically did the following:
- A c# console application that launches another C#(this one is responsible for launching the exe) and exits, the exit is done because If we launch an application directly via custom action the installer will not continue until the custom action closes, so this launcher c# console application does this.
- The launched C# console application has an infinite loop and check in place which looks out for MSI installer running on the system until no installer is running (Note MSI in windows only allow one installer at a time) the the console application launches the exe (I used runas argument in C# code and also made changes to the manifest file of the C# console app such that it runs with admin rights)
- The application (.exe) gets launched but doesn't have admin rights because certain task associated with the application fails unless it is manually run with admin rights by right clicking the exe and selecting run as admin
I also tried writing a vbscript that launches a bat script which does the above task still the same issue.
Maybe I am missing something but I tried allot of things still can't get the application to run with admin rights after installation finishes.