Old 10th April 2019, 13:42   #1
napy2
Junior Member
 
Join Date: Apr 2019
Posts: 3
Exe wont call second exe

Hi guys

I'm hoping someone can help me with the following.

I have a NSIS script that silently copies a load of files to a temp folder (C:\Users\username\AppData\Local\Temp) then runs one of the files (an executable) from this location. A button within this exe is then supposed to launch another exe from the same folder however for some reason this doesn't work and instead exits the program and all the files from the temp folder get removed.

The script reads as follows:

code:
Name "Myapp"
Outfile "Myapp.exe"
InstallDir "$pluginsdir"

Function .onInit
SetSilent silent
FunctionEnd

Section ""

InitPluginsDir
SetOutPath "$pluginsdir"
File /r "C:\tocopy\*"
ExecWait '"$pluginsdir\start.exe"'
SetOutPath $exedir
SectionEnd



Strangely, if I manually run the same exe from the temp folder NSIS writes to so that there are two copies of it running consecutively then click the button that;s supposed to call the other exe it opens as expected!?

Clicking the cancel button on the first exe closes it and deletes all the files from the temp directory which I believe is normal behaviour when using the $pluginsdir. Ideally I don't want it deleting all the files until the second exe has run, the user closes out of this then both exes and all other related files can be removed.

What obvious thing am I missing here?

Thank you
napy2 is offline   Reply With Quote
Old 10th April 2019, 16:32   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
InstallDir "$pluginsdir" is not a good idea but you don't really use $instdir here so it should not matter.

This is not a NSIS issue.

If you are the author of start.exe you can just debug it.

If you are not the author then you can try Process Monitor to see which file it actually tries to execute. I'm guessing there is a current directory issue.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th April 2019, 19:56   #3
napy2
Junior Member
 
Join Date: Apr 2019
Posts: 3
Thank you for replying.

The program is a quick run type of thing (nothing to install) so doesn't really matter where it extracts to. I figured the temp directory would suffice and although it does write everything there as expected it does as you say seem to have a current directory issue as looking at process monitor start.exe is trying to launch the next exe from:

C:\Users\username\AppData\Local\Temp\nsr23A2.tmp\main.exe

Although the actual location of these two files are:

C:\Users\username\AppData\Local\Temp\nsr23A2.tmp\bin\start.exe
C:\Users\username\AppData\Local\Temp\nsr23A2.tmp\bin\main.exe

I've no idea why though as they all copy to the correct place when NSIS runs and start.exe launches fine from the \bin\start.exe location it just decides to look at the folder above for no reason that I can determine. As I said, if I run start.exe from the location above it calls the other exe just fine.



Have also just noticed the line

ExecWait '"$pluginsdir\start.exe"'

in my original post which is wrong. That should actually read

ExecWait '"$pluginsdir\bin\start.exe"'

which is my mistake. It still doesn't call the other exe though...
napy2 is offline   Reply With Quote
Old 10th April 2019, 23:49   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,411
SetOutPath "$pluginsdir" sets the current directory to "C:\Users\username\AppData\Local\Temp\nsr23A2.tmp".

You could try this:

Quote:
Section
InitPluginsDir
SetOutPath "$pluginsdir"
File /r "C:\tocopy\*"

SetOutPath "$pluginsdir\bin" ; Set current directory for buggy app
ExecWait '"$pluginsdir\bin\start.exe"'

SetOutPath $exedir
SectionEnd

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 11th April 2019, 12:48   #5
napy2
Junior Member
 
Join Date: Apr 2019
Posts: 3
Thank you again.

This does solve the issue albeit I know it's a bit of a bodge.
napy2 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump