如何用另一个.exe包装对.exe(带参数)的调用?

时间:2021-03-15 23:19:04

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

我有一个Windows可执行文件(比如program.exe),我想为用户提供2个将为它传递不同参数的启动器。

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.

我可以使用2个批处理文件轻松完成此操作,但我宁愿为用户提供2个.exe文件,因为它们更有可能在没有编辑的情况下正确使用。

Is there an easy way to create such an executable?

有没有简单的方法来创建这样的可执行文件?

6 个解决方案

#1


3  

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

您希望IExpress将批处理文件编译为exe:

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

#2


4  

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

为何创建新的可执行文件?为什么不创建桌面快捷方式来启动单个exe。

#3


0  

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

你可以试试这个: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).

如果你想要真正的,非常小的东西,你可能需要制作自己的Pascal / C程序。我建议使用Pascal,因为有一个非常好的免费编译器可以产生非常小的.EXE,而不需要使用经过调整的库(在这种情况下这将是唯一的C缺点)。

Cheers.

#4


0  

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 ?

这回答了标题中的问题,至于你在这里写的是什么,为什么不解析参数并依赖于它们在一个可执行文件中有两个功能?

#5


0  

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.

如果您的应用程序具有源代码,则可以根据可执行文件的名称更改其行为。这并不难 - 主要是看argv [0]并根据它改变选项。

#6


-1  

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

如果您使用.Net,则可以从其他应用程序或批处理文件中读取作为参数显示的信息。它是框架的一部分。这是VB.NET

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

对于Environment中的每个Arg As String.GetCommandLineArgs()//处理参数Next Arg

#1


3  

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

您希望IExpress将批处理文件编译为exe:

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

#2


4  

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

为何创建新的可执行文件?为什么不创建桌面快捷方式来启动单个exe。

#3


0  

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

你可以试试这个: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).

如果你想要真正的,非常小的东西,你可能需要制作自己的Pascal / C程序。我建议使用Pascal,因为有一个非常好的免费编译器可以产生非常小的.EXE,而不需要使用经过调整的库(在这种情况下这将是唯一的C缺点)。

Cheers.

#4


0  

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 ?

这回答了标题中的问题,至于你在这里写的是什么,为什么不解析参数并依赖于它们在一个可执行文件中有两个功能?

#5


0  

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.

如果您的应用程序具有源代码,则可以根据可执行文件的名称更改其行为。这并不难 - 主要是看argv [0]并根据它改变选项。

#6


-1  

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

如果您使用.Net,则可以从其他应用程序或批处理文件中读取作为参数显示的信息。它是框架的一部分。这是VB.NET

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

对于Environment中的每个Arg As String.GetCommandLineArgs()//处理参数Next Arg