views:

895

answers:

6

I have a Windows executable (say program.exe) and I want to provide users with 2 launchers that will pass different arguments to it.

program.exe -a
program.exe -b

I can easily do this with 2 batch files, but I would rather provide users with 2 .exe files as they are more likely to be used correctly without editing.

Is there an easy way to create such an executable?

A: 

If you are using .Net you can read the information presented as parameters from another application or batch file. It's part of the Framework. Here it is is VB.NET

For Each Arg As String In Environment.GetCommandLineArgs() //Process the arguments Next Arg

stevechol
Well, I don't think that requiring the full .NET framework to just load another program (which might not depend on it) is cool :P
dguaraglia
And requiring me to have Visual Studio! Eww! But thanks anyway!
Liam
A: 

You might try this: http://www.abyssmedia.com/quickbfc/

If you want something really, really small, you'd probably need to make your own Pascal/C program. I suggest Pascal because there is a very nice free compiler that produces really small .EXEs without the need to used a tweaked library (that would be the only C shortcoming in this case).

Cheers.

dguaraglia
A: 

Not sure if its exactly what your trying to do but check this for possible solutions.

That answers the question in the title, as for what you write here, why dont you just parse the arguments and depending on them have the two functionalities inside one executable ?

Roman M
+2  A: 

You want IExpress which compiles your batch file to an exe:

http://renegadetech.blogspot.com/2006/07/how-to-convert-bat-file-or-vbs-file.html

Martin
Excellent! That's a great solution, and it comes with Windows. This will solve more problems than the one I just had! The icon and tooltip of the exe can be edited with ResHacker, giving me exactly what I needed.
Liam
+2  A: 

Why create new executables? Why not just create desktop shortcuts to launch the single exe.

mdresser
So simple! The ability to change the icon is a big advantage over batch files.
Liam
A: 

If you have the source code to your application, you can change its behavior based on the name of the executable. It's not hard - in main, look at argv[0] and change the options based on that.

plinth