Archive: How to execute a file?


How to execute a file?
Hi!
I'm a total noob on NSIS script etc.
But i got one to work when i used the wizard to install a VB6 app that i made.
But if i want to install all the VB6 needed files and have a simple program thats just extracts them, how do i execute this program in the NSIS setup.
I tried the !execute and then the filepath!
But i dont know where to put the !execute line to get it work.

I want to execute this program when all the files that i have added are extracted to the specified dir.
When the installation is in progress i wnat the program to be executed!
anyone know how to do this!?

Greets Duja


!define MUI_FINISHPAGE_RUN "$INSTDIR\YourAppName.exe"

I hope it will help You


If you haven't already, check all the examples in Examples\Modern UI.
You can view the Modern UI (MUI) readme in Contrib\Modern UI\Readme.html

-Stu


Re: How to execute a file?

Originally posted by duja
I want to execute this program when all the files that i have added are extracted to the specified dir.
When the installation is in progress i want the program to be executed!
You can use one of Exec commands or nsexec plug-in (this depends on your program type - Win or DOS) at the end of Section, please read NSIS manual 4.9.1.2-4

Thicos example, isn't that just if you choose to run the program after finished installation?
Because i get an error, look at the line of code:


; Finish page
!define MUI_FINISHPAGE_RUN "$INSTDIR\PcGuard.exe"
!define MUI_FINISHPAGE_RUN "$TEMP\vbrun60sp6.exe"
!insertmacro MUI_PAGE_FINISH


this is the error:
Error in script "C:\Program Files\Microsoft Visual Studio\VB98\PcGuard\SETUP.nsi" on line 42 -- aborting creation process

Anyone know how to just execute this app. to install needed files!?

/ Duja

The MUI_FINISHPAGE_RUN only lets the user choose to run the program after the install is done (you must be using the modern UI for this to be possible). It won't let you execute the defined programs while the installer is still installing.

After extracting the needed files, place

Exec "D:\Path\to\file.exe"

if you want the installation to continue while the file runs. Else, use

ExecWait "D:\Path\to\file.exe"

to make the installer wait for the executed program to finish. I'm guessing that's the one you want.

Alternatively, you could use the nsExec plugin if that's what you need. See the nsExec readme for that.


You missed part of the error. I think it was this...
!define: "MUI_FINISHPAGE_RUN" already defined!
You can't define something twice.

The MUI_FINISHPAGE_RUN define forces MUI to place a check-box on the finish page which allows the user to decide whether he/she wants to run the single executable in question.

To execute a program (or two) 'forcefully' when the user clicks Exit/Close you need to do do this:

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE "execApps"
!insertmacro MUI_PAGE_FINISH

Function "execApps"
Exec "$INSTDIR\PcGuard.exe"
Exec "$TEMP\vbrun60sp6.exe"
FunctionEnd
If one of them is a command-line application (with no graphical user-interface) you can use nsExec::Exec (a plugin) instead of Exec to hide the command-line popup window.

I also recommend you have a message saying that 'appnames' will now run (perhaps a MessageBox). Having two applications with GUI's run at the same time won't make your user's very happy I'm sure...

-Stu

Thank you very much from all help!
I soved it and it works Great now, big thanks to all of you ;)

/ Duja