简体   繁体   中英

Create .exe with Netbeans that allows installation directory selection

I have Netbeans set up on my project so that "Right click project -> Package As -> EXE Installer" will create an executable installer for the application.

The issue is that the installer sets up the application locally in

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

Is there any way to have the installer allow for selecting installation directory or, at the very least, install the application for all users?

usually we use C:\\program files\\...

I ended up no using the tools that Netbeans has built in since I find them very limiting.

Netbeans uses Inno Setup to create its executable files. Though it may exists, I could not find where to edit the script that Inno uses to create those executable files, so I went about it on my own.

I used this guide to combine all the dependencies into my application. If you have more than one, you add extra lines where the file says to do so.

I used Launch4j to package my .jar as a .exe.

I used Inno Setup to take that executable and make an installer with an icon, desktop icon and start menu icon support, and uninstall support. This is the script that I used (mostly generated with the gui) with removed personal info:

; 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

I know this didn't really get a lot of traffic, but I hope it helps anyone that comes across it later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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