PDA

View Full Version : Run Program automatically after install?


Panarchy
27th April 2009, 04:31
Hello

How do I run my program automatically after an install?

Tried following this guide: http://nsis.sourceforge.net/Run_an_application_shortcut_after_an_install but didn't work for me.

Here is my nsi;

!include MUI2.nsh

Name `Maintenance`
OutFile `Maintenance Installer.exe`

BrandingText `Created by Panarchy`

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE license.txt
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE English

Section

!macro ExtractMaintenance ToDir
SetOutPath `${ToDir}`
File "Maintenance Script.exe"
!macroend

!insertmacro ExtractMaintenance "C:\NoWhereInParticular"

CreateShortcut "$DESKTOP\Maintenance.lnk" "C:\NoWhereInParticular\Maintenance Script.exe"

SectionEnd

Please tell me how to integrate a 'run program on finish' feature.

Thanks in advance,

Panarchy

lewellyn
27th April 2009, 06:34
I use something like this:

!define MUI_FINISHPAGE_RUN "$INSTDIR\${PROGEXE}"
!define MUI_FINISHPAGE_RUN_TEXT "Launch ${PRODUCTNAME}"

Yes, I !define PROGEXE and PRODUCTNAME early on in the script (along with lots of other potentially repetitive things). :)

Panarchy
27th April 2009, 07:08
Thanks.

Just tried that, it didn't work.

Please recommend another method.

Thanks in advance,

Panarchy

lewellyn
27th April 2009, 07:10
Can you define "it didn't work"? Did it cause compiler errors? Did it not show the checkbox? Did it not actually launch the exe?

Afrow UK
27th April 2009, 12:05
Make sure you put the defines before !insertmacro MUI_PAGE_FINISH.

Stu

Panarchy
27th April 2009, 23:19
Thanks, I think I finally got it to work.

Panarchy
27th April 2009, 23:30
Confirming;

Yes, it works!!!

Thanks Afrow (and lewellyn for replying...)

ledruide
18th March 2010, 23:29
Any idea on how to start an application after a silent install ?

Can't find anything yet....

Afrow UK
18th March 2010, 23:37
Just put a Section at the end that does it, or use Function .onInstSuccess.

Edit: And if necessary wrap the code inside it with an ${If} ${Silent}.

Stu

ledruide
18th March 2010, 23:42
Function .onInstSuccess
Exec "blablabla.exe"
FunctionEnd

Found your other post, thank you

th_mi
23rd March 2010, 10:07
Function .onInstSuccess
Exec "blablabla.exe"
FunctionEnd


Only as a hint.

If your installer was elevated (under Vista or Seven), the executable started by "Exec" is also elevated. And it is not good to start the application with this privileges without any good reason.

msroboto
23rd March 2010, 15:04
I am using the UAC_AsUser_Execshell from the UAC plug-in.
http://nsis.sourceforge.net/UAC_plug-in

This should prevent the program from running elevated.