Search code examples
c++nsis

Run NSIS installer from a C++ application with out prompting UAC permission


I have C++ application running as service. And I want to start my NSIS installer silently from that service. Is it possible? If yes how can I achieve this?


Solution

  • If you want to start the installer as the same user as your service and this service runs at integrity level high or system then you can just use CreateProcess or ShellExecute to start the installer.

    If you want to start the installer as a user that is currently logged in you need to use CreateProcessAsUser but things get complicated if you go this route. There might not be any logged in users or there might be more than one. Once you have decided which user you want to start the process as then you can get their token with WTSQueryUserToken.