views:

2104

answers:

4

The scenario is that we have a client/server app with the client install being a bootstrapper using Inno Setup that downloads the client from the server specified by IP/Port number. We'd like to be able to detect if there is a server on the local network via UDP broadcasting, and can write a console app that does that. Problem is, how do we pass the information from the console app to the installer?

I can capture the return code, but that can only be an int. As far as I can tell, the only functions to read file in Inno Setup is in the preprocessor so we can't read a file created at runtime by the console app. The only thing I can think of is to return an int where the first 4 digits are the position of the '.'s and : before the port and then parse out the value, which seems hackish, flimsy, and error prone, especially considering I'm not intimately familiar with Inno Setup syntax/functions for constructing a string.

Any suggestions?

+3  A: 

Don't know how to load a parameter from the command line, but you can use LoadStringFromFile to load the contents of a file or GetIniString to read a parameter from an ini file.

More generally, look for "Support Functions Reference" in the Inno Setup Help file. This page will give you a list of all the Inno functions (not including the preprocessor). If you can't find this page (if you only find information about the preprocessor) then you may be looking in the wrong helpfile. Note that the Inno Setup Help table of contents isn't all that great but the index is very good.

Command line parameters are documented on the page "Setup Command Line Parameters". It's possible that you might be able to trick Inno by using one of the existing parameters, but using an ini file seems like it would be the most straightforward approach.

jdigital
In the version I have installed at least it looked like the preprocessor help was merged into the main help file, even though I remember them being separate in an older version of Inno and when searching the index it was hard to tell which were ISPP and which weren't
Davy8
+1  A: 

InnoSetup includes an interpreted Pascal-like extension language that can be used to a lot of things during the installer's runtime.

For instance, I know it can read the registry, and I am fairly sure it can read files, at least from some folders. Your console-mode app could write a temp file or drop one or more registry keys containing the info needed in the rest of the installer, and that can be returned from the scripting environment into the setup script proper. The installer could even clean up the temp file and/or keys later.

RBerteig
A: 

From the Inno Setup manual:

{param:ParamName|DefaultValue}

Embeds a command line parameter value.
    * ParamName specifies the name of the command line parameter to read from.
    * DefaultValue determines the string to embed if the specified command 
      line parameter does not exist, or its value could not be determined.

Example:

[Setup] AppId=... AppName={param:exe_name|xyz}.exe

More: www downloadatoz com/manual/in/inno-setup/topic_consts.htm

That's for passing command line parameters when starting the setup process. The setup executes a command line app that needs to return a value back to a currently running setup.
Davy8