Search code examples
installationnsis

Starting executable after NSIS installer


At the end of my installer, I want to start an .exe file and then end the installation. I have tried various ways to start this exe, shown below, but none of them are quite right. The .exe file brings up a login screen and the user inputs username and password, and a main application starts.

When I double-click the .exe in the folder, it brings up the login prompt, I put in the credentials, and the application starts. The following methods were tried in the installer to replicate this process:

ExecDos async

ExecDos::exec /NOUNLOAD /ASYNC '$Path${APP_FILE_NAME}'
Sleep 30000

ExecShell

ExecShell "" '"$Path${APP_FILE_NAME}"'

ExecDos

ExecDos::exec '$Path${APP_FILE_NAME}'

nsExec

nsExec::exec '$Path${APP_FILE_NAME}'

Ideally, I would like to get the asynchronous call working so it would kick off the login screen and then end of the installer.

All of the above methods present the login screen as expected, but after logging into the application, the main application just sits on a blank gray screen...something I do not see if I simply double click the .exe in the $Path folder and log in normally.

Is there something wrong with making these calls to start the .exe?


Solution

  • The problem is probably with your application and not NSIS...

    If the application depends on the "correct" working directory you need to use SetOutPath first:

    SetOutPath $INSTDIR
    ExecShell "" '"$INSTDIR\myapp.exe"'
    

    Executing the main application at the end of the installer is problematic since it can end up running the app as the wrong user (UAC on, logged in as non-admin and elevating with a admin user (Assuming you did not set RequestExecutionLevel or used RequestExecutionLevel admin))