Skip to content

Commit

Permalink
1.2.4
Browse files Browse the repository at this point in the history
- Replaced TrafficLight with Osprey
- Updated DDU to version 18.0.8.4
- Improved list of bloatware apps
- Bug fixes and improvements
  • Loading branch information
Foulest committed Nov 2, 2024
1 parent c78b9a7 commit 93425b6
Show file tree
Hide file tree
Showing 26 changed files with 226 additions and 178 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = 'net.foulest'
version = '1.2.3'
version = '1.2.4'
description = 'RepairKit'

// Set the language level to Java 17
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/net/foulest/repairkit/RepairKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public static void main(String[] args) {

// Checks if RepairKit is running in the temp directory.
DebugUtil.debug("Checking if RepairKit is running in the temp directory...");
if (System.getProperty("user.dir").equalsIgnoreCase(FileUtil.tempDirectory.getPath())) {
String path = FileUtil.tempDirectory.getPath();

if (System.getProperty("user.dir").equalsIgnoreCase(path)) {
SoundUtil.playSound(ConstantUtil.ERROR_SOUND);
JOptionPane.showMessageDialog(null, ConstantUtil.BAD_FILE_LOCATION, "Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
Expand All @@ -90,13 +92,13 @@ public static void main(String[] args) {

// Deletes pre-existing RepairKit files.
DebugUtil.debug("Deleting pre-existing RepairKit files...");
CommandUtil.runCommand("rd /s /q \"" + FileUtil.tempDirectory.getPath() + "\"", false);
CommandUtil.runCommand("rd /s /q \"" + path + "\"", false);

// Deletes RepairKit files on shutdown.
DebugUtil.debug("Deleting RepairKit files on shutdown...");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
DebugUtil.debug("Shutting down RepairKit...");
CommandUtil.runCommand("rd /s /q \"" + FileUtil.tempDirectory.getPath() + "\"", false);
CommandUtil.runCommand("rd /s /q \"" + path + "\"", false);
}));

// Checks for updates.
Expand All @@ -111,12 +113,14 @@ public static void main(String[] args) {
new RepairKit().setVisible(true);
} catch (RuntimeException ex) {
DebugUtil.warn("Failed to set the program visible", ex);
DebugUtil.debug(Arrays.toString(ex.getStackTrace()));
StackTraceElement[] stackTrace = ex.getStackTrace();
DebugUtil.debug(Arrays.toString(stackTrace));
}
});
} catch (HeadlessException ex) {
DebugUtil.warn("Failed to launch the program", ex);
DebugUtil.debug(Arrays.toString(ex.getStackTrace()));
StackTraceElement[] stackTrace = ex.getStackTrace();
DebugUtil.debug(Arrays.toString(stackTrace));
}
}

Expand Down Expand Up @@ -165,7 +169,8 @@ private RepairKit() {
setLocationRelativeTo(null);
} catch (RuntimeException ex) {
DebugUtil.warn("Failed to create a new instance of the program", ex);
DebugUtil.debug(Arrays.toString(ex.getStackTrace()));
StackTraceElement[] stackTrace = ex.getStackTrace();
DebugUtil.debug(Arrays.toString(stackTrace));
}
}

Expand All @@ -180,7 +185,8 @@ private JPanel createBannerPanel() {
JPanel bannerPanel = new JPanel(new BorderLayout());
bannerPanel.setLayout(null);
bannerPanel.setBackground(new Color(0, 120, 215));
bannerPanel.setPreferredSize(new Dimension(getWidth(), 60));
int width = getWidth();
bannerPanel.setPreferredSize(new Dimension(width, 60));

// Creates the RepairKit icon image.
DebugUtil.debug("Creating the RepairKit icon image...");
Expand Down
70 changes: 38 additions & 32 deletions src/main/java/net/foulest/repairkit/panels/AutomaticRepairs.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ private static void deleteSystemPolicies() {
try {
DebugUtil.debug("Deleting system policies...");
ConfigLoader configLoader = new ConfigLoader(FileUtil.getConfigFile("policies.json"));
RegistryTaskRunner taskRunner = new RegistryTaskRunner(configLoader.getConfig());
Map<String, Map<String, Object>> config = configLoader.getConfig();
RegistryTaskRunner taskRunner = new RegistryTaskRunner(config);
List<Runnable> tasks = taskRunner.getTasks();

// Execute tasks using TaskUtil.
Expand All @@ -263,7 +264,8 @@ private static void removeBloatware() {
try {
DebugUtil.debug("Removing installed bloatware apps...");
ConfigLoader configLoader = new ConfigLoader(FileUtil.getConfigFile("bloatware.json"));
BloatwareTaskRunner taskRunner = new BloatwareTaskRunner(configLoader.getConfig());
Map<String, Map<String, Object>> config = configLoader.getConfig();
BloatwareTaskRunner taskRunner = new BloatwareTaskRunner(config);
List<Runnable> tasks = taskRunner.getTasks();

// Execute tasks using TaskUtil.
Expand All @@ -289,7 +291,7 @@ private static void repairDiskIssues() {

// Repairs the WMI repository.
if (config.get("repairWMI") != null
&& Boolean.TRUE.equals(config.get("repairWMI"))) {
&& config.get("repairWMI").equals(Boolean.TRUE)) {
DebugUtil.debug("Repairing WMI repository...");

if (CommandUtil.getCommandOutput("winmgmt /verifyrepository", false, false).toString().contains("not consistent")
Expand All @@ -303,15 +305,15 @@ private static void repairDiskIssues() {

// Repairs disk issues with SFC.
if (config.get("repairWithSFC") != null
&& Boolean.TRUE.equals(config.get("repairWithSFC"))) {
&& config.get("repairWithSFC").equals(Boolean.TRUE)) {
DebugUtil.debug("Repairing disk issues with SFC...");

if (CommandUtil.getCommandOutput("sfc /scannow", false, false).toString().contains("Windows Resource Protection found")) {
DebugUtil.debug("Found disk issues with SFC.");

// Repairs disk issues with DISM.
if (config.get("repairWithDISM") != null
&& Boolean.TRUE.equals(config.get("repairWithDISM"))) {
&& config.get("repairWithDISM").equals(Boolean.TRUE)) {
DebugUtil.debug("Repairing disk issues with DISM...");
CommandUtil.runCommand("DISM /Online /Cleanup-Image /RestoreHealth", false);
DebugUtil.debug("Repaired disk issues with DISM.");
Expand All @@ -332,18 +334,19 @@ private static void runRegistryTweaks() {
try {
DebugUtil.debug("Running registry tweaks...");
ConfigLoader configLoader = new ConfigLoader(FileUtil.getConfigFile("registry.json"));
RegistryTaskRunner taskRunner = new RegistryTaskRunner(configLoader.getConfig());
Map<String, Map<String, Object>> config = configLoader.getConfig();
RegistryTaskRunner taskRunner = new RegistryTaskRunner(config);
List<Runnable> tasks = taskRunner.getTasks();
Map<String, Object> config = configLoader.getConfig().get("spectreMeltdown");
Map<String, Object> spectreMeltdown = configLoader.getConfig().get("spectreMeltdown");

// Checks if the config is null.
if (config == null) {
if (spectreMeltdown == null) {
return;
}

// Patches Spectre & Meltdown security vulnerabilities.
if (config.get("enabled") != null
&& Boolean.TRUE.equals(config.get("enabled"))) {
if (spectreMeltdown.get("enabled") != null
&& spectreMeltdown.get("enabled").equals(Boolean.TRUE)) {
tasks.add(() -> {
String cpuName = CommandUtil.getCommandOutput("wmic cpu get name", false, false).toString();
RegistryUtil.setRegistryIntValue(WinReg.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management", "FeatureSettingsOverrideMask", 3);
Expand Down Expand Up @@ -384,7 +387,7 @@ private static void runSystemTweaks() {

// Fixes micro-stuttering in games.
if (config.get("platformTickClock") != null
&& Boolean.TRUE.equals(config.get("platformTickClock"))) {
&& config.get("platformTickClock").equals(Boolean.TRUE)) {
tasks.add(() -> {
CommandUtil.runCommand("bcdedit /set useplatformtick yes", true);
CommandUtil.runCommand("bcdedit /deletevalue useplatformclock", true);
Expand All @@ -393,13 +396,13 @@ private static void runSystemTweaks() {

// Enables scheduled defrag.
if (config.get("scheduledDefrag") != null
&& Boolean.TRUE.equals(config.get("scheduledDefrag"))) {
&& config.get("scheduledDefrag").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runCommand("schtasks /Change /ENABLE /TN \"\\Microsoft\\Windows\\Defrag\\ScheduledDefrag\"", true));
}

// Disables various telemetry tasks.
if (config.get("telemetry") != null
&& Boolean.TRUE.equals(config.get("telemetry"))) {
&& config.get("telemetry").equals(Boolean.TRUE)) {
tasks.add(() -> {
CommandUtil.runCommand("schtasks /change /TN \"Microsoft\\Windows\\Application Experience\\Microsoft Compatibility Appraiser\" /disable", true);
CommandUtil.runCommand("schtasks /change /TN \"Microsoft\\Windows\\Application Experience\\ProgramDataUpdater\" /disable", true);
Expand All @@ -415,19 +418,19 @@ private static void runSystemTweaks() {

// Deletes the controversial 'defaultuser0' user.
if (config.get("defaultuser0") != null
&& Boolean.TRUE.equals(config.get("defaultuser0"))) {
&& config.get("defaultuser0").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runCommand("net user defaultuser0 /delete", true));
}

// Clears the Windows product key from registry.
if (config.get("productKey") != null
&& Boolean.TRUE.equals(config.get("productKey"))) {
&& config.get("productKey").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runCommand("cscript.exe //nologo \"%SystemRoot%\\system32\\slmgr.vbs\" /cpky", true));
}

// Resets network settings.
if (config.get("networkReset") != null
&& Boolean.TRUE.equals(config.get("networkReset"))) {
&& config.get("networkReset").equals(Boolean.TRUE)) {
tasks.add(() -> {
CommandUtil.runCommand("netsh winsock reset", true);
CommandUtil.runCommand("netsh int ip reset", true);
Expand All @@ -441,13 +444,13 @@ private static void runSystemTweaks() {

// Re-registers ExplorerFrame.dll.
if (config.get("explorerFrame") != null
&& Boolean.TRUE.equals(config.get("explorerFrame"))) {
&& config.get("explorerFrame").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runCommand("regsvr32 /s ExplorerFrame.dll", true));
}

// Disables NetBios for all interfaces.
if (config.get("netBios") != null
&& Boolean.TRUE.equals(config.get("netBios"))) {
&& config.get("netBios").equals(Boolean.TRUE)) {
String baseKeyPath = "SYSTEM\\CurrentControlSet\\services\\NetBT\\Parameters\\Interfaces";
java.util.List<String> subKeys = RegistryUtil.listSubKeys(WinReg.HKEY_LOCAL_MACHINE, baseKeyPath);

Expand All @@ -459,7 +462,7 @@ private static void runSystemTweaks() {

// Resets Windows Media Player.
if (config.get("mediaPlayer") != null
&& Boolean.TRUE.equals(config.get("mediaPlayer"))) {
&& config.get("mediaPlayer").equals(Boolean.TRUE)) {
tasks.add(() -> {
CommandUtil.runCommand("regsvr32 /s jscript.dll", false);
CommandUtil.runCommand("regsvr32 /s vbscript.dll", true);
Expand All @@ -482,7 +485,8 @@ private static void runFeaturesTweaks() {
try {
DebugUtil.debug("Running Windows features tweaks...");
ConfigLoader configLoader = new ConfigLoader(FileUtil.getConfigFile("features.json"));
FeaturesTaskRunner taskRunner = new FeaturesTaskRunner(configLoader.getConfig());
Map<String, Map<String, Object>> config = configLoader.getConfig();
FeaturesTaskRunner taskRunner = new FeaturesTaskRunner(config);
List<Runnable> tasks = taskRunner.getTasks();

// Execute tasks using TaskUtil.
Expand All @@ -501,7 +505,8 @@ private static void runCapabilitiesTweaks() {
try {
DebugUtil.debug("Running Windows capabilities tweaks...");
ConfigLoader configLoader = new ConfigLoader(FileUtil.getConfigFile("capabilities.json"));
CapabilitiesTaskRunner taskRunner = new CapabilitiesTaskRunner(configLoader.getConfig());
Map<String, Map<String, Object>> config = configLoader.getConfig();
CapabilitiesTaskRunner taskRunner = new CapabilitiesTaskRunner(config);
List<Runnable> tasks = taskRunner.getTasks();

// Execute tasks using TaskUtil.
Expand All @@ -519,7 +524,8 @@ private static void runServicesTweaks() {
try {
DebugUtil.debug("Running services tweaks...");
ConfigLoader configLoader = new ConfigLoader(FileUtil.getConfigFile("services.json"));
ServicesTaskRunner taskRunner = new ServicesTaskRunner(configLoader.getConfig());
Map<String, Map<String, Object>> config = configLoader.getConfig();
ServicesTaskRunner taskRunner = new ServicesTaskRunner(config);
List<Runnable> tasks = taskRunner.getTasks();

// Execute tasks using TaskUtil.
Expand All @@ -543,15 +549,15 @@ private static void scanForMalware() {
// Scan with Windows Defender if enabled and running.
if (defenderRunning && defenderConfig != null
&& defenderConfig.get("enabled") != null
&& Boolean.TRUE.equals(defenderConfig.get("enabled"))) {
&& defenderConfig.get("enabled").equals(Boolean.TRUE)) {
scanWithWindowsDefender(defenderConfig);
}

// Scan with Sophos if enabled.
if (sophosConfig != null
&& sophosConfig.get("enabled") != null
&& Boolean.TRUE.equals(sophosConfig.get("enabled"))) {
if (Boolean.TRUE.equals(sophosConfig.get("onlyRunAsBackup")) && defenderRunning) {
&& sophosConfig.get("enabled").equals(Boolean.TRUE)) {
if (sophosConfig.get("onlyRunAsBackup").equals(Boolean.TRUE) && defenderRunning) {
DebugUtil.debug("Skipping Sophos scan; Windows Defender is running.");
} else {
scanWithSophos();
Expand All @@ -571,15 +577,15 @@ private static void scanWithWindowsDefender(@NotNull Map<String, Object> defende

// Enables Windows Firewall for all profiles.
if (defenderConfig.get("fixFirewall") != null
&& Boolean.TRUE.equals(defenderConfig.get("fixFirewall"))) {
&& defenderConfig.get("fixFirewall").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runPowerShellCommand("Set-NetFirewallProfile"
+ " -Profile Domain,Private,Public"
+ " -Enabled True", false));
}

// Removes all Windows Defender exclusions.
if (defenderConfig.get("removeExclusions") != null
&& Boolean.TRUE.equals(defenderConfig.get("removeExclusions"))) {
&& defenderConfig.get("removeExclusions").equals(Boolean.TRUE)) {
tasks.add(() -> {
CommandUtil.runPowerShellCommand("Get-MpPreference | Select-Object -ExpandProperty"
+ " ExclusionPath | ForEach-Object { Remove-MpPreference -ExclusionPath $_ }", false);
Expand Down Expand Up @@ -608,7 +614,7 @@ private static void scanWithWindowsDefender(@NotNull Map<String, Object> defende

// Removes all previous Windows Defender settings.
if (defenderConfig.get("removePreviousSettings") != null
&& Boolean.TRUE.equals(defenderConfig.get("removePreviousSettings"))) {
&& defenderConfig.get("removePreviousSettings").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runPowerShellCommand("Remove-MpPreference"
+ " -RealTimeScanDirection"
+ " -QuarantinePurgeItemsAfterDelay"
Expand Down Expand Up @@ -698,7 +704,7 @@ private static void scanWithWindowsDefender(@NotNull Map<String, Object> defende

// Sets Windows Defender to recommended settings.
if (defenderConfig.get("setRecommendedSettings") != null
&& Boolean.TRUE.equals(defenderConfig.get("setRecommendedSettings"))) {
&& defenderConfig.get("setRecommendedSettings").equals(Boolean.TRUE)) {
tasks.add(() -> CommandUtil.runPowerShellCommand("Set-MpPreference"
+ " -CloudBlockLevel 4"
+ " -CloudExtendedTimeout 10"
Expand Down Expand Up @@ -728,7 +734,7 @@ private static void scanWithWindowsDefender(@NotNull Map<String, Object> defende

// Sets Windows Defender ASR rules to recommended settings.
if (defenderConfig.get("setASRRules") != null
&& Boolean.TRUE.equals(defenderConfig.get("setASRRules"))) {
&& defenderConfig.get("setASRRules").equals(Boolean.TRUE)) {
tasks.add(() -> {
CommandUtil.runPowerShellCommand("Add-MpPreference"
+ " -AttackSurfaceReductionRules_Ids "
Expand Down Expand Up @@ -770,15 +776,15 @@ private static void scanWithWindowsDefender(@NotNull Map<String, Object> defende
// Updates Windows Defender signatures.
if (!RepairKit.isSafeMode()
&& defenderConfig.get("updateSignatures") != null
&& Boolean.TRUE.equals(defenderConfig.get("updateSignatures"))) {
&& defenderConfig.get("updateSignatures").equals(Boolean.TRUE)) {
DebugUtil.debug("Updating Windows Defender signatures...");
CommandUtil.runCommand("\"C:\\Program Files\\Windows Defender\\MpCmdRun.exe\" -SignatureUpdate", false);
DebugUtil.debug("Completed Windows Defender signature update.");
}

// Runs a quick scan with Windows Defender.
if (defenderConfig.get("runQuickScan") != null
&& Boolean.TRUE.equals(defenderConfig.get("runQuickScan"))) {
&& defenderConfig.get("runQuickScan").equals(Boolean.TRUE)) {
DebugUtil.debug("Running a quick scan with Windows Defender...");
CommandUtil.runCommand("\"C:\\Program Files\\Windows Defender\\MpCmdRun.exe\" -Scan -ScanType 1", false);
DebugUtil.debug("Completed Windows Defender quick scan.");
Expand Down
Loading

0 comments on commit 93425b6

Please sign in to comment.