Archive: Option to launch application after install


Option to launch application after install
Hello

I'm sorry to be a newbie with NSIS but I do not find howto add an option to launch the application after installation

Does anyone can help me ?
Thanks for any help

Here the end of my script
CreateShortCut "$DESKTOP\MapScope.lnk" "$INSTDIR\Mapscope.exe" ""
${registerExtension} "$INSTDIR\Mapscope.exe" ".mmdl" "MapScope_Map_File"
${registerExtension} "$INSTDIR\Mapscope.exe" ".mtpl" "MapScope_Template_File"
!define MUI_FINISHPAGE_RUN "$DESKTOP\MapScope.lnk"
SectionEnd


When you use the MUI the order of the MUI commands is important. This is mentioned in the MUI ReadMe:

Script header

The settings for the Modern UI should be inserted in the header of the script file. It's important to follow the same order as the items below. For example, interface settings should be defined before you insert pages, because the pages depend on the interface configuration. It may be useful to look at the example scripts too see how this is done in actual script files.
MUI_FINISHPAGE_RUN should be defined before the "!insertmacro MUI_PAGE_FINISH" line in your script. See the makensis.nsi script in the Examples folder to see an example which uses MUI_FINISHPAGE_RUN.

From the MUI ReadMe:
MUI_FINISHPAGE_RUN exe_file
Application which the user can select to run using a checkbox. You don't need to put quotes around the filename when it contains spaces.
To run the Mapscope.exe program from the FINISH page, use something like this:
!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"

!insertmacro MUI_PAGE_FINISH

Thank for your help

I'm probably stupid but altough I'have good experience in C, C++, C# the logic of NSIS script remain obscure to me

I've tryed your suggestion

(sorry I do not found too how to add code or qoute tag) : other forums have options to do it

code:
CreateShortCut "$DESKTOP\MapScope.lnk" "$INSTDIR\Mapscope.exe" ""
${registerExtension} "$INSTDIR\Mapscope.exe" ".mmdl" "MapScope_Map_File"
${registerExtension} "$INSTDIR\Mapscope.exe" ".mtpl" "MapScope_Template_File"
!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
!insertmacro MUI_PAGE_FINISH
SectionEnd


But I get the error :

quote:

Error: command AutoCloseWindow not valid in Section
Error in macro MUI_PAGE_FINISH on macroline 26
Error in script "D:\projets\MapScope.v2\setupMapscope\setupML.nsi" on line 150 -- aborting creation process


You have put the MUI commands in the wrong place so you are getting errors.

As I said earlier, the MUI ReadMe explains the order in which the MUI commands need to appear.

The MUI page commands need to come BEFORE the sections as shown in, for example, the WelcomeFinish.nsi script.

NSIS comes with lots of examples which are useful if you have trouble understanding the documentation. Try compiling and using these examples to get familiar with NSIS. You can then try copying and modifying some example scripts to get more experience.

The MUI ReadMe even has an "Example scripts" section with links to several MUI example scripts (including WelcomeFinish.nsi):
http://nsis.sourceforge.net/Docs/Mod....html#examples

If you use the "Post a Reply" button you will find it easier to select tags to mark code, etc,


Thank you

I finaly have found that I have to put the macro insert AFTER the SectionEnd tag (example below)

BUT now I see a Finishing blank page with a check box without any text ?
How can I define a text like "Do you want to launch MapScope"

NSIS is certainly powerfull but very difficult to understand !

But I'm stupid :cry:

NB : How can I define a code or quote block in this forum ? in many other forum I just have to mark a text block then use the # or Quote button : those button seems to have no effect in this forum : just gives a 'blong' when pressing
So I enter them manualy


  CreateShortCut "$DESKTOP\MapScope.lnk" "$INSTDIR\Mapscope.exe" ""
${registerExtension} "$INSTDIR\Mapscope.exe" ".mmdl" "MapScope_Map_File"
${registerExtension} "$INSTDIR\Mapscope.exe" ".mtpl" "MapScope_Template_File"
!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
SectionEnd


!insertmacro MUI_PAGE_FINISH

You will find it easier if you follow the instructions in the MUI ReadMe and look at the example scripts. Note that the MUI ReadMe is quite long and by default all of the sections are collapsed - the "[Expand all]" link at the top of the ReadMe is an easy way to display the entire ReadMe.

Here is a tiny demo that might help

  !include "MUI2.nsh"

Name "Notepad Demo"
OutFile "finish_demo.exe"

RequestExecutionLevel user

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "notepad.exe"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

Section "One" SecOne

SetOutPath "$INSTDIR"

;ADD YOUR OWN FILES HERE...

SectionEnd
The attached screenshot shows the FINISH page (which simply starts the Windows notepad program).

Hello

I thank you for your help and patience but I really do not understand why there is no message to launch the installed program

The install works fine
The launch too

But no message ?
Whe do I have to define that message ?

I'll send you the full script


Try moving the MUI_FINISHPAGE_RUN and MUI_PAGE_FINISH lines up to the place where the other MUI pages are defined.

You can use MUI_FINISHPAGE_RUN_TEXT to define the text shown next to the 'Run program' checkbox.

  !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Run the Mapscope program now"
!insertmacro MUI_PAGE_FINISH

Thanks a lot again

Your help is appreciated !
Step by step I understand and it comes to work :)

So 'one" of the last problem is to define the message for each language

I'm using this :
.. it is working but it gives a warning during compilation (see below)

What am I doing wrong now ?


;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English" ;first language is the default language
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Dutch"

;--------------------------------
;Reserve Files

;If you are using solid compression, files that are required before
;the actual installation should be stored first in the data block,
;because this will make your installer start faster.

!insertmacro MUI_RESERVEFILE_LANGDLL

LangString end ${LANG_ENGLISH} "Run MapScope"
LangString end ${LANG_DUTCH} "Start MapScope"
LangString end ${LANG_GERMAN} "Start MapScope"
LangString end ${LANG_FRENCH} "Démarrer MapScope"


;---
!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
!define MUI_FINISHPAGE_RUN_TEXT "$(end)"
;!define MUI_FINISHPAGE_RUN_TEXT "Run the Mapscope program now"
!insertmacro MUI_PAGE_FINISH


Warning messages (part of 24)
LangString "MUI_BUTTONTEXT_FINISH" is not set in language table of language Dutch
LangString "MUI_BUTTONTEXT_FINISH" is not set in language table of language German
LangString "MUI_BUTTONTEXT_FINISH" is not set in language table of language French
LangString "MUI_BUTTONTEXT_FINISH" is not set in language table of language English

Hello again

I have a look in the different language file, so I found that there is a predefined string for the launch checkbox

MUI_TEXT_FINISH_RUN

But there is two question

1- Why this message does not comes automaticaly as many other : MUI_TEXT_INSTALLING_SUBTITLE for example

I've tryed this

!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
!define MUI_FINISHPAGE_RUN_TEXT $MUI_TEXT_FINISH_RUN
!insertmacro MUI_PAGE_FINISH

But it display $MUI_TEXT_FINISH_RUN
And I still get the warnings

I've tryed to invert like this

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

Now I do not get any warning anymore
But the finish page is never shown
:igor:


The reason for all the "LangString "MUI_BUTTONTEXT_FINISH" is not set in language table" messages is that your script does not have things in the correct order. Here is a modified version of the simple script I provided earlier:

  !include "MUI2.nsh"

Name "Notepad Demo #2"
OutFile "finish_demo_2.exe"

RequestExecutionLevel user

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "notepad.exe"
!define MUI_FINISHPAGE_RUN_TEXT "$(end)"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Dutch"

!insertmacro MUI_RESERVEFILE_LANGDLL

LangString end ${LANG_ENGLISH} "Run Notepad"
LangString end ${LANG_DUTCH} "Start Notepad"
LangString end ${LANG_GERMAN} "Start Notepad"
LangString end ${LANG_FRENCH} "Démarrer Notepad"

Function .onInit

!insertmacro MUI_LANGDLL_DISPLAY

FunctionEnd

Section "One" SecOne

SetOutPath "$INSTDIR"

;ADD YOUR OWN FILES HERE...

SectionEnd
This compiles without any warnings and the attached screenshot shows the FINISH page displayed if "French" is selected when the demo is run.
I have a look in the different language file, so I found that there is a predefined string for the launch checkbox

MUI_TEXT_FINISH_RUN
The MUI ReadMe explains how to set up the defines and other settings needed by the MUI system. I suggest you re-read the documentation and look again at the examples. There is no need to look into the various language files, especially since you are still having trouble using MUI.
!insertmacro MUI_PAGE_FINISH
!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
does not work because the lines are in the wrong order. The MUI ReadMe describes the order and position in which the MUI commands have to be used. MUI_FINISHPAGE_RUN is a setting for the FINISH page. The "Page settings" section of the MUI ReadMe says "Page settings apply to a single page and should be set before inserting a page macro." So you need to put the MUI_FINISHPAGE_RUN line before the MUI_PAGE_FINISH line.

Thank you

It works now without having to define any MUI_FINISHPAGE_RUN_TEXT

When you've tryed 100 trick you always think that you don't have missed the 101 one !

Here is the code

!define MUI_FINISHPAGE_RUN "$INSTDIR\Mapscope.exe"
; !define MUI_FINISHPAGE_RUN_TEXT "$(end)"
!insertmacro MUI_PAGE_FINISH

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English" ;first language is the default language
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Dutch"

Glad to hear that your script works now.

MUI_FINISHPAGE_RUN_TEXT lets you change the default text. If the default text is OK then you do not need to use MUI_FINISHPAGE_RUN_TEXT.