问题
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?
回答1:
Why create new executables? Why not just create desktop shortcuts to launch the single exe.
回答2:
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.
回答3:
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 ?
回答4:
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.
回答5:
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
来源:https://stackoverflow.com/questions/166493/how-can-i-wrap-a-call-to-an-exe-with-arguments-with-another-exe