Hey, I'm in the final stages of a portable app launcher, but for one final configuration piece, I need to pass a string to the launcher from another .exe (basically, as a command line parameter), so basically the launcher would be called by the command "MyPortableLauncher.exe" -stringgoeshere
Basically, I'm passing the launcher an environment variable that exists only within the app itself and is semi-random (I think it's user-specific), and other weird stuff, so I can only get the string into the launcher in one of two ways, both involving passing via a parameter in an executable call.
First, I could just call the launcher with the command-line parameter. However, I don't believe this is supported by NSIS (I think NSIS only supports a few specific parameters, such as silent install, etc.).
So, if this can't work with NSIS, I could build a 2-part launcher (with 2 separate .exes) where the first part was writtin in some other language other than NSIS and then run the NSIS launcher. In this case, I'll call the first part "LaunchConfig.exe" and the second "PortableApp.exe" (the second one works basically the same as the "Portable{AppName}.exe" launchers found in any of the programs on this site.
I would call the program with the command
LaunchConfig.exe -stringparameter
which would do the following:
-write "stringparameter" as an entry in an .ini file
-launch "PortableApp.exe"
Then, it would be very simple to read the .ini entry with NSIS and implement it into the launcher.
I'm basically stymied as to how to go about this, so if anyone could help me out with this I would really appreciate it. And before anyone asks, yes the string DOES have to be passed via command-line, I have tried other ways, but I really believe this is the only way to make it work.
use an INI file...
Insert original signature here with Greasemonkey Script.
Writing 2 launchers makes no sense. If you'll use another language, write everything in it. And this is the route I would suggest.
"Those people who think they know everything are a great annoyance to those of us who do." Asimov
There are examples of launchers who do this. For example the FireFor cauncher accepts command line parameters and parses them to the original exe. (For example opening a html page)
My own launcher should also be able to do that.
Please check out some existing launchers or check the NSIS documentation for more information on this.
Turns out NSIS can indeed read the environment variable using ReadEnvString, I had just added the "%" character so I got errors that the launcher couldn't access the environment... apparently the % is only used on the ENVIRONMENT side to pass the variable, not the reading side.
Quamquam omniam nescio, nec nihil scio.
Sorry, but I thought you were referring to command line parameters...
I WAS referring to command-line parameters, passing an environment variable to the launcher via command-line, because when I tested my launcher using NSIS's ReadEnvString command, the variable just showed up blank, so I thought that for some reason it couldn't read it, so I figured that a workaround was to pass the environment variable via the command line, but it turns out that the problem was in the syntax like I said. It all works now. Probably the biggest problem was that I wrote the original launcher at like 2 in the morning so I wasn't seeing the real problem (syntax... stupid me :P).
Quamquam omniam nescio, nec nihil scio.
You don't need to pass environment variables on the commandline. That's what makes them part of the "environment": you just set the variable and read it in the child process.