I am sure someone must have run into a similar problem before. I am putting Freemind (the beloved java mind map/tree structure organiser) on my PortableApps stick. Seeing how nice it is to work with the menu I am dead set on building a menu launcher with NSIS - after all I love the apps and the menu and I cringe every time I click through folders to launch my app. What happens is:
1) I put a copy of jawa into PortableApps\CommonFiles
2) I create a bat file which by itself works fine. My main need/reason for bat is because I want the settings to be stored on my flash drive - not in the default dir determined by local machine environment.
@echo off
..\..\..\CommonFiles\cmdow\cmdow @ /hid
..\..\..\CommonFiles\Java\bin\java -Duser.home=..\..\Data -cp lib\freemind.jar;lib\ant\lib\jaxb-api.jar;lib\ant\lib\jaxb-impl.jar;lib\ant\lib\jaxb-libs.jar;lib\ant\lib\namespace.jar;lib\ant\lib\relaxngDatatype.jar;lib\ant\lib\xsdlib.jar;lib\ant\lib\jax-qname.jar;lib\ant\lib\sax.jar;lib\ant\lib\dom.jar freemind.main.FreeMind > out.txt 2> err.txt
..\..\..\CommonFiles\cmdow\cmdow @ /vis
As you notice if the file is run, it produces 2 output files err.txt and out.txt
3) I attempt to create launcher via NSIS using the recommended SumatraPDF.nsi as template. It does NOT work for the bat file. I try to put it in the same dir as the launcher, change paths in it, I test it separately - it works. But launcher does not seem to run it anyways (no err.txt and no out.txt is produced).
4) I can create a working launcher however in the same setup easily for the freemind.exe. The downside of course is - freemind.exe (apparently freemind's own launcher) uses the system (not memstick) java installation and stores all settings in my system home directory - not on memory stick. (sigh)
I would really appreciate if someone with computer knowledge could advise me on this - I am a complete newbie with NSIS.
Thanks guys for your help!
You might want to look at the source code for CommandPromptPortable for an example of how to call a .bat file; perhaps that might solve the problem.
MC
You of course are right in that. I will experiment. Still it is nice when someone who knows what the problem is explains to you - I spent the whole afternoon evening doing the above procedure since I am not a programmer and I didn't know anything about NSIS.
A lot of programming is experimenting.
By getting a batch file working, you're part of the way there. What's left is working out the idiosyncracies.
I don't think I've ever made a batch file with relative directories (..\), to be called by another app, where I didn't have to fix something to make it work, like making sure I was starting in the right path.
The first step is to make sure that the launcher is calling the .bat file.
The next thing I might do is comment out the @echo off, and put a "pause" for the last line, to make sure I could see the result (just for testing). You could add a line with just "cd" (no quotes) to see what directory it is working in.
Let us know how things are going, we might have some other pointers.
I could be wrong (I'm not an NSIS expert either) but I suspect eventually you should be able to issue all the commands currently in that batch file from NSIS, which would be more elegant, even if it is a bit harder to implement.
MC
In your batch file just put
And see if the launcher is executing the batch file in the root directory. If it is then you have to put the .bat file in the APP\APPNAME directory so the launcher can find it, then still cd into it from your batch file, even though it's already there.
.bat file in APP\APPNAME
Simply put the APPNAME.bat filename in the .nsi file where ever the normal APPNAME.exe would go.
Hope this helps.
rab040ma is right about running the commands right from the launcher.
NSIS does have a shell execute type command. I read about it, but it should be able to replace your batch commands, I haven't tried it yet. Something like
Have an Awesome Day!
Thanks guys for the advice. This is really constructive and I will try this out tonight when I return home from work.
Thanks again. It now works very well. Your advice helped - I took cmd prompt portable as base. Then I made sure that launcher made by nsis executed the bat file, after that it was as simple as getting the right directories. What apparently threw me a bit was even though bat file is called the execution still remains in nsis launcher directory. Therefore the first line of the script should change directory to the bat file's. (Or any of your choice really - as long as the paths in the bat file make sense).
So now I have great and useful Freemind in my menu, works fine, I have given it to a few friends as well. If anyone needs any help, please drop me a line.
Cheers