Archive: Launch an .exe file after install?


Launch an .exe file after install?
Well I'm making a uninstaller that installs something.
And how can I make the uninstaller open an .exe file right after you click close etc. (It's a kind of scanner) Scans a folder for something, if it detects, it deletes the files.

Here's my code:


;------------------------------------------------------
!include "MUI.nsh"

Name "moh_breakthrough_demo"
OutFile "moh_breakthrough_demo.exe"

InstallDir "$PROGRAMFILES\EA GAMES\Medal of Honor Allied Assault Breakthrough Demo\"

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "moh_header.bmp"

!define MUI_ABORTWARNING
!define MUI_WELCOMEFINISHPAGE_BITMAP "moh_wizard.bmp"

!define MUI_ICON "arrow2-install.ico"

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Section hideuinstaller

HideWindow

SectionEnd

Section "scan" scan

Delete "$INSTDIR\genocide.dll"

SectionEnd

Section openfile

Exec '"$INSTDIR\moh_breakthrough.exe" "parameter 1" "parameter 2"'

SectionEnd

Section close

SetAutoClose true

SectionEnd

;--------------------------------------------------------



And when I try to run the uninstall i can see it delete the file.. but when it closes a problem pops up:


http://img263.imageshack.us/img263/9...unchmfcfo7.jpg

Help :D?

According to the name the dialog displays it seems the application you're executing is crashing.


But when I exec a normal .txt file from notepad.. The same thing happends? :/


With the exact same text? Where does this text come from? What program of yours is called "Launch MFC"? Look for that program as that's the one that is crashing.


Oh now it doesn't even open the .txt file when i tested. And I think it's the moh_breakthrough.exe that's called Launch MFC... Well it's not running the .txt file either? Could that be a script problem?

Also:
Could it be because I use Vista x64? 64-bit..


Nothing in NSIS itself is called "Launch MFC" and nothing in the script you've provided is called "Launch MFC". You must first find out what is this "Launch MFC" thing in order to find out what's wrong.


That is a crash associated with the Quake 3 engine launcher (in your case moh_breakthrough.exe). I seem to remember (i.e. games like MOH, ET). If it is crashing then the game isn't installed properly.

Stu


Hmmm.. Could it be because it's a cracked .exe? For allowing mods into the game. Maybe that's why its crashing?.. Maybe I should try to run some other file :)


Just a quick thought here but did you try using the un.onUninstSuccess function? It is called after the uninstaller is finished.


Well, I made a batch file thought.. Made it lanuch the batch file then lanuch the game file :S It worked then, Wierd eh. But I'll try that Fightin_Foo But first.. Eh this isn't a uninstaller, it's like a scanner. But I made it as an installer :)


Try setting the working directory first to the same directory that contains the executable with SetOutPath.

Stu


InstallDir "$PROGRAMFILES\EA GAMES\Medal of Honor Allied Assault Breakthrough Demo\"

Exec '"$INSTDIR\moh_breakthrough.exe" "parameter 1" "parameter 2"'

So you mean I should place it in same directory as the "scanner" ?


Originally posted by Afrow UK
Try setting the working directory first to the same directory that contains the executable with SetOutPath.

Stu
Damn ! that solved a problem i had launching an .exe on .onInstSuccess. The .exe i was trying to launch with Exec command was generating errors. If i ran manually the .exe no problem, so i created a batch file to launch installer then application. In the NSIS script, i was copying a file to a subdirectory of the application to launch, then tried to exec the .exe but got errors, i just added the red part to the script as below :

# Installer sections
Section -Main SEC0000
SetOutPath $EXEDIR\SubDir
SetOverwrite on
File myfile.ext
SectionEnd

Function .onInstSuccess
SetOutPath $EXEDIR
Exec '"App.exe"'
FunctionEnd


And now it works like a charm.

Hope that tip can help ppl in the future...

Thx 4ever Afrow UK !

Sorry for (very) explanation and (very) bad english ^^