diff --git a/pom.xml b/pom.xml
index d4b7c89..1f35540 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,10 +98,5 @@
commons-lang
2.6
-
- com.github.vatbub
- mslinks
- 1.0.6.2
-
\ No newline at end of file
diff --git a/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java b/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java
index cf51554..6ecbaaf 100644
--- a/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java
+++ b/src/main/java/de/chaos/swlnmngr/route/routes/InstallRoute.java
@@ -2,26 +2,23 @@ package de.chaos.swlnmngr.route.routes;
import de.chaos.swlnmngr.Main;
import de.chaos.swlnmngr.config.CLIConfig;
-import mslinks.ShellLink;
import org.apache.commons.lang.SystemUtils;
import org.json.JSONObject;
import org.json.JSONTokener;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
-import java.nio.file.attribute.FileAttribute;
-import java.nio.file.attribute.PosixFilePermission;
import java.util.Objects;
public class InstallRoute implements Route {
- private static final String[] defaultFiles = new String[] {"default_swlnmngr.bat", "default_swlnmngr.sh"};
+ private static final String[] defaultFiles = new String[] {"default_swlnmngr.bat", "default_swlnmngr.sh", "default_swlnmngr_admin.bat"};
@Override
public String getName() {
@@ -61,10 +58,8 @@ public class InstallRoute implements Route {
}
} else if(SystemUtils.IS_OS_WINDOWS) {
try {
- ShellLink link = ShellLink.createLink(new File(CLIConfig.INSTALL_DIR, "swlnmngr.bat").getAbsolutePath(), new File(CLIConfig.INSTALL_DIR, "swlnmngr.lnk").getAbsolutePath()).setWorkingDir(CLIConfig.INSTALL_DIR.getAbsolutePath());
- link.getHeader().getLinkFlags().setRunAsUser();
- link.saveTo(new File(CLIConfig.INSTALL_DIR, "swlnmngr.lnk").getAbsolutePath());
Files.writeString(new File(CLIConfig.INSTALL_DIR, "swlnmngr.bat").toPath(), Files.readString(new File(CLIConfig.INSTALL_DIR, "swlnmngr.bat").toPath()).replace("${iDir}", CLIConfig.INSTALL_DIR.getAbsolutePath()), StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING);
+ Files.writeString(new File(CLIConfig.INSTALL_DIR, "swlnmngr_admin.bat").toPath(), Files.readString(new File(CLIConfig.INSTALL_DIR, "swlnmngr_admin.bat").toPath()).replace("${iDir}", CLIConfig.INSTALL_DIR.getAbsolutePath()), StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException e) {
Main.getLogger().error("Could not create Link", e);
return false;
diff --git a/src/main/resources/default_swlnmngr.bat b/src/main/resources/default_swlnmngr.bat
index eb0de03..f8a4e14 100644
--- a/src/main/resources/default_swlnmngr.bat
+++ b/src/main/resources/default_swlnmngr.bat
@@ -1,5 +1,16 @@
+@echo off
+:: Variables
+SET JavaHome=java
+
+:: Code
+title Request Admin
+
+Net session >nul 2>&1 || (PowerShell start -verb runas '%~0' & exit)
+
+title SteamWarLinkManager
set args=--help
set /p args=Arguments:
echo %args%
-java -jar ${iDir}\SteamWarLinkManager.jar %args% %*
-pause
\ No newline at end of file
+%JavaHome% -jar ${iDir}\SteamWarLinkManager.jar %args% %*
+pause
+exit
\ No newline at end of file
diff --git a/src/main/resources/default_swlnmngr_admin.bat b/src/main/resources/default_swlnmngr_admin.bat
new file mode 100644
index 0000000..9dce24f
--- /dev/null
+++ b/src/main/resources/default_swlnmngr_admin.bat
@@ -0,0 +1,5 @@
+@echo off
+
+title Admin
+runas /noprofile /savecred /user:Admin ${iDir}\swlnmngr.bat
+exit
\ No newline at end of file