【发布时间】:2016-12-09 14:27:00
【问题描述】:
我正在使用 maven 的 launch4j 插件从现有的 jar 构建 .exe 文件。 我想创建 .exe 文件,它会自动需要管理员角色来运行它。可以通过插件实现吗?如果确实可以通过launch4j maven插件找到一些信息,我无法找到。
谢谢, 安德烈
【问题讨论】:
标签: java maven executable-jar launch4j
我正在使用 maven 的 launch4j 插件从现有的 jar 构建 .exe 文件。 我想创建 .exe 文件,它会自动需要管理员角色来运行它。可以通过插件实现吗?如果确实可以通过launch4j maven插件找到一些信息,我无法找到。
谢谢, 安德烈
【问题讨论】:
标签: java maven executable-jar launch4j
似乎需要使用清单文件,其中指定由 maven4j 插件构建的这个 .exe 文件应该需要管理员角色才能打开它。就launch4j插件而言,这意味着在应指定清单文件路径的地方添加特殊标签
所以配置如下:
<configuration>
<headerType>gui</headerType>
<outfile>target/${maser.app.jar.name}64.exe</outfile>
<jar>target/${maser.app.jar.name}.jar</jar>
<manifest>src/main/resources/${maser.app.jar.name}64.exe.manifest</manifest>
<jre>
<path>bin/${jre64.path}/</path>
<opts>
<opt>-Djava.library.path="dll"</opt>
</opts>
</jre>
<versionInfo>
...
</versionInfo>
</configuration>
清单文件看起来像:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
【讨论】: