package it.ksuploader.main;


import it.ksuploader.utils.Environment;
import it.ksuploader.utils.LoadConfig;
import it.ksuploader.utils.MyKeyListener;
import java.io.File;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import net.jimmc.jshortcut.JShellLink;

public class Main {
    public static Environment so = new Environment();
    public static LoadConfig config = new LoadConfig();
    public static MyKeyListener keyListener;
    public static PrintWriter log;
    public static SystemTrayMenu st;

	public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        log = new PrintWriter(so.getInstallDir().getPath() + "//log.txt");
        keyListener = new MyKeyListener();
        st = new SystemTrayMenu();
        startUpCheck(config.isStartUpEnabled());
	}
    
    public static void startUpCheck(boolean active) {
        if(active){
            JShellLink shortcut = new JShellLink();
            shortcut.setPath(new File("KSUploader.jar").getAbsolutePath());
            shortcut.setName("KSUploader");
            shortcut.setFolder(Main.so.getStartUpFolder());
            shortcut.save();
        } else {
            System.out.println(new File(Main.so.getStartUpFolder(),"KSUploader.lnk").delete());
        }
        
    }

	public static void myLog(String s) {
		System.out.println(s);
		log.println(s);
		log.flush();
	}

	public static void myErr(String s) {
		log.println(s);
		log.flush();
	}

}
@@ -284,24 +284,154 @@
 Exception;%0D%0A
+import java.net.URISyntaxException;%0D%0Aimport java.util.Arrays;%0D%0Aimport java.util.logging.Level;%0D%0Aimport java.util.logging.Logger;%0D%0A
 import net.j
@@ -813,16 +813,36 @@
 xception
+, URISyntaxException
  %7B%0D%0A    
@@ -1104,24 +1104,131 @@
  active) %7B%0D%0A
+        myLog(%22%5BMain%5D removing shortcut%22+new File(Main.so.getStartUpFolder(),%22KSUploader.lnk%22).delete());%0D%0A
         if(a
@@ -1236,16 +1236,39 @@
 tive)%7B%0D%0A
+            try %7B%0D%0A    
         
@@ -1316,32 +1316,36 @@
 );%0D%0A            
+    
 shortcut.setPath
@@ -1358,24 +1358,78 @@
 ile(
-%22KSUploader.jar%22
+Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()
 ).ge
@@ -1443,24 +1443,28 @@
 tePath());%0D%0A
+    
             
@@ -1491,21 +1491,35 @@
 Uploader
+_autostart
 %22);%0D%0A
+    
         
@@ -1575,32 +1575,36 @@
 );%0D%0A            
+    
 shortcut.save();
@@ -1617,14 +1617,94 @@
     
-%7D else
+        myLog(%22%5BMain%5D Shortcut created%22);%0D%0A            %7D catch (URISyntaxException ex)
  %7B%0D%0A
@@ -1715,35 +1715,201 @@
         
+  
-System.out.println(
+  ex.printStackTrace();%0D%0A                myErr(Arrays.toString(ex.getStackTrace()).replace(%22,%22, %22%5Cn%22));%0D%0A            %7D%0D%0A        %7D else %7B%0D%0A            myLog(%22%5BMain%5D removing shortcut%22+
 new File

fix startup again