Archive: Two Problems


Two Problems
1) MUI_FINISHPAGE_RUN

this works:
!define MUI_FINISHPAGE_RUN "$INSTDIR\test1.exe"

but this does not:
!define MUI_FINISHPAGE_RUN "$INSTDIR\subfolder1\subfolder2\test2.exe"

which doesn't make sense to me at all. why not? we have a full qualifying path, so it should work.

2) CreateShortCut

will not work:

CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\MyApp.lnk" "$INSTDIR\system\myapp.exe" /command_line_switch_for_myapp

there is no way to pass any command line arguments to myapp.exe during the creation of my shortcuts. i've tried everything i can think of, but nsis keeps assuming too many things. it either adds my /switch inside the quotes (which won't work, ex: "c:\myapp.exe /test") or it tries assuming that my /switch is another nsis parameter, such as an icon or hotkey.

i need workarounds, hax, fixes, anything that works!

thanks!


This works fine for me :-

CreateShortCut "${NSISDIR}\blah.lnk" "${NSISDIR}\makensisw.exe" "/?"

Hi,

In regards to your second problem with CreateShortcut, it sounds like your command line switch contains spaces in it. For example:

CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\MyApp.lnk" "$INSTDIR\system\myapp.exe" /whoop C:\Tick Tock\bing.txt

will consider:

"/whoop" as the command line switch,
"C:\Tick" as the icon file, and
"Tock\bing.txt" as the icon_index_number.

(I know hard coding file locations is bad practice, I'm just trying to illustrate how spaces in paths can also delimit parameters)

Wrap your command line switches in quotes (don't forget to escape them if necessary) and that should bring joy into your life. For example:

CreateShortCut "$SMPROGRAMS\${MUI_STARTMENUPAGE_VARIABLE}\MyApp.lnk" "$INSTDIR\system\myapp.exe" "/whoop \$"C:\Tick Tock\bing.txt\$""

(Don't know about your first problem - for a stab in the dark, could it relate to escaping quotes? All I can say is that from my recent conversion to MUI, when I define MUI symbols, I can't use statements like

!define MUI_FINISHPAGE_RUN '"wrapping quotes"'

anymore, but I can use

!define MUI_FINISHPAGE_RUN "\$"wrapping quotes\$""

Other than that, I can't see why your exact example wouldn't work. Would it help if you post the exact line from your script which is failing?)

Ta,
Dave.


Item #2 CreateShortcut is working fine, I had an extra set of quotes after the command line parameter that was throwing it off. And if I create a shortcut to a long filename path, it does it correctly (in the created shortcut) by encasing the path and exe in quotes, but not the extra params:

"c:\a long filename path test\myapp.exe" /ahh

Item #1 MUI_FINISHPAGE_RUN is not working, no matter what I try. I think I've expired all of the possibilities here:

!define MUI_FINISHPAGE_RUN $INSTDIR\subfolder1\subfolder2\myapp.exe

!define MUI_FINISHPAGE_RUN '$INSTDIR\subfolder1\subfolder2\myapp.exe'

!define MUI_FINISHPAGE_RUN "$INSTDIR\subfolder1\subfolder2\myapp.exe"

!define MUI_FINISHPAGE_RUN `$INSTDIR\subfolder1\subfolder2\myapp.exe`

!define MUI_FINISHPAGE_RUN "$\"$INSTDIR\subfolder1\subfolder2\myapp.exe$\""

No matter what I try, the app I want to run cannot and will not run, ever. It just can't be in a subfolder or a series of subfolders --- it's like it absolutely has got to be in the same folder as $INSTDIR.

i need a workaround or a fix! :/


is the file you want to run already there? i had this problem when copied some files in .oninstsuccess and wanted to display it like that. you have to move the copying into a section in this case.


my mui defines are all at the top of my nsis script, including the finish page. the files are all copied in my first section.

i don't know, it just doesn't make sense. the path is 100% correct, i've even checked it with a messagebox, but it just will not run myapp.exe when i click finish unless myapp.exe is in $INSTDIR -- it can't be anywhere else on my hard drive. way too restrictive.


Attach the script and I'll have a look.


ok, god i'm stupid. nested folders work fine for the finish page.

here's my real problem though, and i can't figure out a way to do it.

i don't just want to run the exe on the finish page, i want to change directories... into the same folder as the exe that i am attempting to run.

on finish i need to run a starter exe 2 subfolders deep, to execute some commands and then it automatically cd's up 2 folders back to $INSTDIR and runs the real exe.

well, the finish page runs my starter exe, but since it is in $INSTDIR and hasn't changed into the subfolders, when the starter exe is done, it tries going up two folders above $INSTDIR -- and the real exe can't be found then.

if that makes sense at all. you can tell i'm out of coffee. so, is there a way to change directories for the finish page run command?

and wouldn't it be a better idea anyway to automatically chdir into the same folder as the exe we want to run?


Exec and ExecWait start the program with $OUTDIR as the working directory. Set it using SetOutPath or just copy a value in to it.


ok, how do i tell MUI_FINISHPAGE_RUN to use $OUTDIR? i mean, i added SetOutPath in like 20 places (at the end of each section) hoping it would work, but MUI_FINISHPAGE_RUN seems to only rely on $INSTDIR. so, when i click finish, i can run an exe from anywhere on my harddrive, but it never changes to the same directory that the contains that exe.


The MUI never uses SetOutPath and NSIS doesn't change $OUTDIR unless you use SetOutPath or copy something into it so the last directory set as $OUTDIR will be used. Use SetOutPath in the finish page's pre function or the last section.


ok, i give up. i have setoutpath at the end of every section (16 total) yet MUI_FINISHPAGE_RUN still fails to change directories to $OUTPATH, or somehow it is being reset to $INSDIR --- and i don't see an example of a finish page's pre function anywhere so i guess i'll have to try something else instead. :(


!define MUI_CUSTOMFUNCTION_FINISH_PRE myFinishPre

Function myFinishPre
SetOutPath "$INSTDIR\system\mpp"
FunctionEnd

annoying... this fails too. it just will not chdir to the folder of the exe being run.


Works fine for me and it doesn't relay on any change I have made to the latest CVS version. It should even work on 1.98 (executing a program at the end using .onInstSuccess for example). Try setting MUI_FINISHPAGE_RUN to the attached program, it'll tell you the working directory. Maybe it will help you see where the problem is.


ok, i feel stupid. :p~

!define MUI_CUSTOMFUNCTION_FINISH_PRE myFinishPre

Function myFinishPre
SetOutPath "$INSTDIR\system\mpp"
FunctionEnd

this worked, but in all of my previous attempts i forgot to change this:

!define MUI_FINISHPAGE_RUN $OUTDIR\subfolder1\subfolder2\myapp.exe

back to $INSTDIR

it seems to work now. ugh. sorry for the bs. i wish i had seen MUI_CUSTOMFUNCTION_FINISH_PRE sooner.

thanks kichik!

oh, i also tested your file, it works also. mine reports the current folder too, which is how i saw it failing.

anyway, thanks again! :)