简体   繁体   English

Inno Setup:如何启动带参数的可执行文件

[英]Inno Setup : how to launch an executable with parameters

I have a custom Java runtime image for Windows called java.exe and I can simply execute java -jar HelloWorld.jar to run my HelloWorld application.我有一个用于 Windows 的自定义 Java 运行时映像,名为java.exe ,我可以简单地执行java -jar HelloWorld.jar来运行我的 HelloWorld 应用程序。 Using Inno Setup, I want to create an installer for my HelloWorld application.使用 Inno Setup,我想为我的 HelloWorld 应用程序创建一个安装程序。 I can create an installer for java.exe , but obviously it would just run my custom Java image, whereas what I want is to run java -jar HelloWorld.jar .我可以为java.exe创建一个安装程序,但显然它只会运行我的自定义 Java 图像,而我想要的是运行java -jar HelloWorld.jar

Does anyone know how this can be achieved?有谁知道这是如何实现的? Inno Setup does not seem to support application parameters. Inno Setup 似乎不支持应用程序参数。

I found a hack, which is to create a batch file that would execute my command.我发现了一个技巧,即创建一个批处理文件来执行我的命令。 The problem is that it opens an extra CMD window. I was able to overcome this using a visual basic script that calls the batch file.问题是它会打开一个额外的 CMD window。我能够使用调用批处理文件的可视化基本脚本来克服这个问题。 It works, but I wonder if there is a better way.它有效,但我想知道是否有更好的方法。

Based on the Inno Setup design, the way to pass parameters to the executable (Java in this case) is via the parameters configuration of the [icon] section.基于 Inno Setup 设计,将参数传递给可执行文件(在本例中为 Java)的方式是通过 [icon] 部分的参数配置。 And using “minimized” in the Flags of the [icon] would cause the application to launch without opening any CMD windows. The only downside of using [icon] parameters is that they are visible and modifiable by right clicking on the application icon.在 [icon] 的Flags中使用“最小化”会导致应用程序在不打开任何 CMD windows 的情况下启动。使用 [icon] 参数的唯一缺点是它们是可见的,并且可以通过右键单击应用程序图标进行修改。 An alternative approach is to create a.bat file, or better yet: a.exe file that calls the application with the required parameters.另一种方法是创建一个 .bat 文件,或者更好:一个 .exe 文件,它使用所需的参数调用应用程序。 If using.exe, then a simple call to execv would do.如果使用 .exe,则只需调用 execv 即可。 There's no need to fork.没有必要分叉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM