how to host an exe with a dynamic commandline parameter - exe

I have an installer exe which takes a channel_id param as a command line parameter and uses it.
The channel_id may be different for different downloads and installs.
I want to host my installer exe on web in such a way that when it's downloaded and executed (by double clicking) the channel_id is passed to it in someway ,which should be equivalent to running the installer exe in cmd with channel_id as below.
cmd> myinstaller.exe channel_id.
How is it possible to do so ?

You can append data to the end of the .exe file.

You can include your param in the name of the file. For example, instead of setup.exe, call it setup_XXXX.exe. Then from NSIS you can read and parse $EXEPATH and extract your param from the filename.

Probably not the most reliable way to do this (if there is any), but you could probably check for the Zone.Identifier. I'm not aware of a way to this natively in NSIS, but you might be able to achieve by parsing the result through the commandline.
Try
nsExec::ExecToLog 'more < "$EXEPATH:Zone.Identifier"'
or
nsExec::ExecToLog 'dir /r "$EXEPATH"'
I've also found several Powershell (and VisualBasic) scripts that allow interacting with Alternate Data Streams, but personally I'm not a big fan of using third party scripting languages.

Related

Reg:ILMerge for exe files

I am trying to merge two exe file using ILMerge. When I execute the merged exe, it is only execuing the primary exe..Could any one tell me how an ILMerge can be used for merging the exe files
Based on information from here and here, what you want is not possible. Only one EXE can run.
For ilmerge.exe, the first file argument is treated as primary, others will be packaged as DLLs. How the primary file will work is something you can control using a command line argument t (you need /t:exe, but it will only run one file, the first one).
The t parameter is used to set output type: exe for Console app, winexe for Windows forms, librarys for DLL.

File script searching for versioning

I need to search through all sub directories of a directory and find all files containing a "VERSION" string including a number.
I need to increment this number, so 1.1.2 will be incremented to 1.1.3 etc. and save it in the file again.
I need to run this on Windows machines only, if it makes any difference.
Can I do this with cmd commands or do I need to use a program for this ?
I would like to run this without installing anything if possible.
I ended up writing a Java program to go through the entire structure.
I found that using CMD commands was too complicated for me to structure, and using a Java program I could also easily reuse parts of the program in different but similar structures elsewhere in my file system.
The CMD usage could my the files for me, but extract a single line, manipulating it and putting it back inside the file was not easy using CMD commands, where as using Java was much easier.

Compiling and executing an nsi file from another nsi file using nsis code

Suppose I have two nsi files demo.nsi (compiles to demo.exe) and setup.nsi. (compiles to setup.exe). I want to use demo.nsi inside setup.nsi in such a way that when setup.exe is executed, it compiles the demo.nsi, and then executes the demo.exe.
Just want to know if that is possible to do in nsis ?
Thanks.
Sure, it could be possible like from e.g. any batch file:
you need to call ExecWait to call makensis.exe for the compilation part
and you can call the final executable with either ExecWait or Exec depending on you need to wait for the result or not.
Beware that if you want to do that in any host, and not only the one where you prepare your setup, you will have to embed the NSIS distribution in your setup to be able to call makensis.exe and all the included files that could be necessary (included files, plugins, and other resources).

How to run an ant script from VC++

Assume a Visual C++ solution that outputs several executables. These executables are meant to be run in a certain order and with certain parameters -- and for this purpose there already is an ant build.xml script.
What would be a decent approach to integrating this ant script with VC++, such that the ant script will point against the recently output executables (.\Debug and .\Release folders) and ideally could be run directly from VC++, and dare I say with remote debugging.
I was thinking of using build post-events that populate a build.properties file with the output location of each executable, and let the ant script use this .properties file.
Any help on the matter would be great.
I'm not sure if there is a good answer for this. Perhaps you are not asking the right questions. From C++ you can launch anything, including scripts. I'm not sure what you mean by VC++ integration.
The generic answer would be:
save the output locations somewhere, doesn't matter where (file, registry, environment variables etc.)
retrieve them in the script before use
But depending on what you need, you could also try:
Output the same executables in the same folder structure. This way you can use relative paths.
Use a post-build event which copies the script in the output folder and make it use the relative path.
Instead of a script you can also try handling everything from the first EXE. Instead of an ANT script it could use a configuration file which specifies execution order and parameters.

Is it possible to control which files to install from command line for INNO installer?

I would like to control a subset of files and only allow some of them to be installed if run with a command line switch for instance.
Is this possible?
For example
if (some condition)
install full set of files
else
Install other set of files
Alternatively I can just run another installer but then I have to pass the file/path location to that second installer. There is also the issue of bundling that second installer with the first one. I think that part is not that difficult though
Yes, it is even rather easy. There are several ways to do this, all of which depend on Pascal scripting.
Method 1
You can use the GetCmdTail, ParamCount, and ParamStr functions to obtain the entire or parts of the command-line.
Then you can use the Check parameter on separate files. Hence, each file will be installed if and only if the called function returns true.

Resources