You are here

passing a string to the launcher

8 posts / 0 new
Last post
qwertymodo
qwertymodo's picture
Offline
Last seen: 11 years 9 months ago
Joined: 2008-03-17 19:08
passing a string to the launcher

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.

digitxp
digitxp's picture
Offline
Last seen: 12 years 7 months ago
Joined: 2007-11-03 18:33
Or,

use an INI file...

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 13 years 2 months ago
Joined: 2006-12-12 12:00
Writing 2 launchers makes no

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

LOGAN-Portable
LOGAN-Portable's picture
Offline
Last seen: 11 years 3 months ago
Developer
Joined: 2007-09-11 12:24
There are examples of

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.

qwertymodo
qwertymodo's picture
Offline
Last seen: 11 years 9 months ago
Joined: 2008-03-17 19:08
it was syntax... gah

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.

LOGAN-Portable
LOGAN-Portable's picture
Offline
Last seen: 11 years 3 months ago
Developer
Joined: 2007-09-11 12:24
Sorry, but I thought you

Sorry, but I thought you were referring to command line parameters...

qwertymodo
qwertymodo's picture
Offline
Last seen: 11 years 9 months ago
Joined: 2008-03-17 19:08
I WAS referring to

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 Shock so I wasn't seeing the real problem (syntax... stupid me :P).

Quamquam omniam nescio, nec nihil scio.

Bruce Pascoe
Offline
Last seen: 12 years 3 months ago
Joined: 2006-01-15 16:14
*is confused*

You don't need to pass environment variables on the commandline. Shock That's what makes them part of the "environment": you just set the variable and read it in the child process.

Log in or register to post comments