Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch an executable on the end of installation with proper rights?

I'm launching my Windows application this way after the installation completes:

!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchApplication"

...

Function LaunchApplication
    ExecShell "" "$INSTDIR\Application.exe"
FunctionEnd

But this has a strange and undesired side-effect. Apparently is my application launched with admin rights.

I cannot drag & drop any data between a web browser (tested with Firefox and IE) and my application.

If I quit my application (the session started from NSIS), and restart it from the start menu icon everything works! - I can drag & drop to the browsers without problems.

So I suspect since in the beginning of installation there is a UAC request, somehow UAC rights are transferred to the process I'm launching after installation. Since the browsers run in a low security process Windows refuses to exhange any data with them (in the process instance that is launched with NSIS).

How to launch an exe from NSIS, so that this UAC/security problem does not happen?

like image 398
Casady Avatar asked May 15 '13 02:05

Casady


2 Answers

Try This:

!define MUI_FINISHPAGE_RUN "$INSTDIR\Application.exe"
!insertmacro MUI_PAGE_FINISH

OR

Function .oninstsuccess   
Exec "$INSTDIR\Application.exe"   
FunctionEnd
like image 108
foobar Avatar answered Dec 09 '22 15:12

foobar


I recommend using the plugin ShellExecAsUser as mentioned by Anders. I use it for this exact same purpose like this:

!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApplication

...

Function LaunchApplication
   SetOutPath $INSTDIR
   ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\Application.exe" ""
FunctionEnd

Note the use of SetOutPath to ensure that Application.exe starts with installation folder as it's current directory. ShellExecAsUser does not set this.

like image 40
lnordeide Avatar answered Dec 09 '22 15:12

lnordeide