使用允许安装目录选择的Netbeans创建.exe

时间:2015-06-24 18:47:42

标签: java windows netbeans exe

我在项目中设置了Netbeans,因此“右键单击项目 - > Package As - > EXE Installer”将为应用程序创建可执行安装程序。

问题是安装程序在本地设置应用程序

C:\%USERNAME%\AppData\Local\ApplicationName

有没有办法让安装程序允许选择安装目录,或者至少为所有用户安装应用程序?

通常我们使用C:\program files\...

1 个答案:

答案 0 :(得分:1)

我最终没有使用Netbeans内置的工具,因为我发现它们非常有限。

Netbeans使用Inno Setup创建其可执行文件。虽然它可能存在,但我找不到编辑Inno用来创建这些可执行文件的脚本的位置,所以我自己去做了。

我使用this指南将所有依赖项合并到我的应用程序中。如果您有多个,则在文件说明的位置添加额外的行。

我使用Launch4j将.jar打包为.exe。

我使用Inno Setup获取该可执行文件,并使用图标,桌面图标和开始菜单图标支持制作安装程序,并卸载支持。这是我使用的脚本(主要是使用gui生成的)删除了个人信息:

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId=generated guid
AppName=app name
AppVersion=1.0
;AppVerName=app version name
AppPublisher=company name
AppPublisherURL=company name
AppSupportURL=company site
AppUpdatesURL=company site
DefaultDirName={pf}\app name
DefaultGroupName=app name
AllowNoIcons=yes
OutputDir=output directory
OutputBaseFilename=setup
SetupIconFile=icon directory
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "exe location"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\application name"; Filename: "{app}\exe file"
Name: "{group}\{cm:UninstallProgram,application name}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\application name"; Filename: "{app}\application name.exe"; Tasks: desktopicon

[Run]
Filename: "{app}\application name.exe"; Description: "{cm:LaunchProgram,application name}"; Flags: nowait postinstall skipifsilent

我知道这并没有真正获得大量流量,但我希望它可以帮助后来遇到它的任何人。