From 9a0e00f474a1b39c179728f34aca36330b036592 Mon Sep 17 00:00:00 2001 From: RPJosh Date: Sun, 7 May 2023 17:08:50 +0200 Subject: [PATCH] [Windows] Add option to add programm to autostart --- .../de/rpjosh/installer/InstallConfig.java | 5 +++-- .../java/de/rpjosh/installer/Installer.java | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/rpjosh/installer/InstallConfig.java b/src/main/java/de/rpjosh/installer/InstallConfig.java index 687223d..42a0cd7 100644 --- a/src/main/java/de/rpjosh/installer/InstallConfig.java +++ b/src/main/java/de/rpjosh/installer/InstallConfig.java @@ -360,9 +360,10 @@ public class InstallConfig { } /** - * [Linux] Creates an auto start for your GUI application that will be started directly after the window manager was loaded + * Creates an auto start entry for your GUI application that will be started directly after the window manager + * / the desktop was loaded * - * @param user User for which the GUI should be started + * @param user [Linux] User for which the GUI should be started. This information is only required for linux * @param startFlags Execution flags to add to the launch script like "--minimized" */ public void createGuiAutostart(String user, String startFlags) { diff --git a/src/main/java/de/rpjosh/installer/Installer.java b/src/main/java/de/rpjosh/installer/Installer.java index 0fb15a6..b4ac883 100644 --- a/src/main/java/de/rpjosh/installer/Installer.java +++ b/src/main/java/de/rpjosh/installer/Installer.java @@ -299,8 +299,23 @@ public class Installer { // Creates a Link that the program can be launched from everywhere // this.createLauncher("", "", true); - // create also an link for the %PATH% variable - if (conf.createPathVariable) this.createLauncher("", conf.getApplicationDir() + "path/" + conf.getApplicationNameShort() + ".bat", true); + + // Create also an link for the %PATH% variable + if (conf.createPathVariable) { + this.createLauncher("", conf.getApplicationDir() + "path/" + conf.getApplicationNameShort() + ".bat", true); + } + + // Create a GUI auto start file // + if (conf.createGuiAutostart) { + String pathMenu = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\" + conf.getApplicationNameShort() + ".lnk"; + + // Create an autostart file only for the current user + if (conf.getIsUser()) { + pathMenu = System.getenv("APPDATA") + "\\Microsoft\\Windows\\Start Menu\\Programs\\Autostart\\" + conf.getApplicationNameShort() + ".lnk"; + } + + this.createDesktopShortcut(pathMenu, conf.guiAutostartFlags); + } // in the first step a desktop shortcut will be created //