Skip to content

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
- Automatic Repairs now allows for manual selection
- Expanded Automatic Repairs checkboxes options
- Replaced WinGet-AutoUpdate with built-in alternative
- Fixed capabilities tweaks not working correctly
- Modified configuration files to work with new structure
- Bug fixes and improvements
  • Loading branch information
Foulest committed Nov 18, 2024
1 parent ba5da2f commit ece1acc
Show file tree
Hide file tree
Showing 17 changed files with 327 additions and 208 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ Automatically perform a comprehensive system cleanup and repair, including:
- Removing pre-installed bloatware
- Cleaning unnecessary junk files
- Repairing various disk issues
- Updating outdated installed programs
- Scanning for malware with security software

Every function in the repair is fully customizable, allowing you to enable or disable specific repairs as needed using
the configuration files located in the **config** folder. **Only modify these files if you know what you are doing.**
either the checkboxes on the panel, or the configuration files located in the **config** folder. **Only modify these
files if you know what you are doing.**

> **Note:** The malware scan automatically runs a quick scan with Windows Defender. In the event that Windows Defender
> is disabled or unavailable, a quick scan is performed with Sophos Scan & Clean instead.
![Automatic Repairs](https://i.imgur.com/zqSGyy7.png)
![Automatic Repairs](https://i.imgur.com/xLZoNXh.png)

### **Useful Programs**

Expand All @@ -56,14 +58,12 @@ Access essential software tools for system maintenance, including:
processes.
- **[BlueScreenView](https://nirsoft.net/utils/blue_screen_view.html)**: View and analyze Windows BSOD crash dumps.

- **[Winget-AutoUpdate](https://github.com/Romanitho/Winget-AutoUpdate)**: Automatically update installed programs using
Winget.
- **[NVCleanstall](https://techpowerup.com/download/techpowerup-nvcleanstall)**: A lightweight NVIDIA graphics card
driver updater.
- **[DisplayDriverUninstaller](https://guru3d.com/files-details/display-driver-uninstaller-download.html)**: Remove
display drivers and packages.

![Useful Programs (Page 1/2)](https://i.imgur.com/3H0geaW.png)
![Useful Programs (Page 1/2)](https://i.imgur.com/xZxomZf.png)

Additionally, RepairKit provides links to useful software tools, including:

Expand All @@ -78,7 +78,7 @@ Additionally, RepairKit provides links to useful software tools, including:
- **[Twinkle Tray](https://twinkletray.com)**: Link to the monitor brightness control software.
- **[FanControl](https://getfancontrol.com)**: Link to the fan speed control software.

![Useful Programs (Page 2/2)](https://i.imgur.com/GZZ4cSl.png)
![Useful Programs (Page 2/2)](https://i.imgur.com/MMaiGzM.png)

### **System Shortcuts**

Expand All @@ -90,7 +90,7 @@ Quickly access important Windows utilities like:
- Windows Security
- Task Manager

![System Shortcuts](https://i.imgur.com/efbPJ8M.png)
![System Shortcuts](https://i.imgur.com/OTog97t.png)

## Download and Run

Expand Down
6 changes: 5 additions & 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.4'
version = '1.2.5'
description = 'RepairKit'

// Set the language level to Java 17
Expand Down Expand Up @@ -37,6 +37,10 @@ dependencies {
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'

// two-slices - for sending toasts
// https://github.com/sshtools/two-slices
implementation group: 'com.sshtools', name: 'two-slices', version: '0.9.4'

// JetBrains Annotations - for code inspection and documentation
// https://mvnrepository.com/artifact/org.jetbrains/annotations
compileOnly group: 'org.jetbrains', name: 'annotations', version: '26.0.1'
Expand Down
186 changes: 156 additions & 30 deletions src/main/java/net/foulest/repairkit/panels/AutomaticRepairs.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class AutomaticRepairs extends JPanel {
/**
* Creates the Automatic Repairs panel.
*/
@SuppressWarnings("NestedMethodCall")
public AutomaticRepairs() {
// Sets the panel's layout to null.
DebugUtil.debug("Setting the Automatic Repairs panel layout to null...");
Expand Down Expand Up @@ -99,21 +100,38 @@ public AutomaticRepairs() {
"Delete System Policies",
"Run Registry Tweaks",
"Run System Tweaks",
"Run Features Tweaks",
"Run Capabilities Tweaks",
"Run Services Tweaks",
"Remove Junk Files",
"Remove Bloatware",
"Repair Disk Issues",
"Scan for Malware"
"Scan for Malware",
"Update Outdated Programs"
};

// Creates the progress checkboxes.
DebugUtil.debug("Creating the Automatic Repairs progress checkboxes...");
progressCheckboxes = new JCheckBox[progressItems.length];
int numberOfItems = progressItems.length;

int x = 16;
int y = 235;
int maxWidth = 450;
int checkboxHeight = 28;
int checkboxWidth = 220; // Adjust width as needed

for (int i = 0; i < numberOfItems; i++) {
progressCheckboxes[i] = new JCheckBox(progressItems[i]);
progressCheckboxes[i].setFont(new Font(ConstantUtil.ARIAL, Font.PLAIN, 14));
progressCheckboxes[i].setBounds(16, 235 + (i * 28), 500, 30);
progressCheckboxes[i].setEnabled(false);
progressCheckboxes[i].setBounds(x, y, checkboxWidth, checkboxHeight);
progressCheckboxes[i].setSelected(false);

y += checkboxHeight;
if (y + checkboxHeight > maxWidth) {
y = 235;
x += checkboxWidth;
}
}

// Adds the progress checkboxes to the panel.
Expand All @@ -130,6 +148,7 @@ public AutomaticRepairs() {
/**
* Runs the automatic repairs.
*/
@SuppressWarnings("NestedMethodCall")
private void runAutomaticRepairs() {
DebugUtil.debug("Running Automatic Repairs...");

Expand All @@ -141,6 +160,54 @@ private void runAutomaticRepairs() {
// Creates a new thread to run the automatic repairs.
Thread repairThread = new Thread(() -> {
try {
// Sets the state of all checkboxes to variables.
boolean deleteSystemPolicies = progressCheckboxes[0].isSelected();
boolean runRegistryTweaks = progressCheckboxes[1].isSelected();
boolean runSystemTweaks = progressCheckboxes[2].isSelected();
boolean runFeaturesTweaks = progressCheckboxes[3].isSelected();
boolean runCapabilitiesTweaks = progressCheckboxes[4].isSelected();
boolean runServicesTweaks = progressCheckboxes[5].isSelected();
boolean removeJunkFiles = progressCheckboxes[6].isSelected();
boolean removeBloatware = progressCheckboxes[7].isSelected();
boolean repairDiskIssues = progressCheckboxes[8].isSelected();
boolean scanForMalware = progressCheckboxes[9].isSelected();
boolean updateOutdatedPrograms = progressCheckboxes[10].isSelected();

// Disables all checkboxes.
for (JCheckBox checkbox : progressCheckboxes) {
checkbox.setEnabled(false);
checkbox.setSelected(false);
}

// Checks if no repair options are selected.
if (!deleteSystemPolicies
&& !runRegistryTweaks
&& !runSystemTweaks
&& !runFeaturesTweaks
&& !runCapabilitiesTweaks
&& !runServicesTweaks
&& !removeJunkFiles
&& !removeBloatware
&& !repairDiskIssues
&& !scanForMalware
&& !updateOutdatedPrograms) {
SoundUtil.playSound(ConstantUtil.ERROR_SOUND);
JOptionPane.showMessageDialog(null, "Please select at least one repair option.", "Error", JOptionPane.ERROR_MESSAGE);

// Resets the run button.
DebugUtil.debug("Resetting the run button...");
runButton.setEnabled(true);
runButton.setBackground(new Color(0, 120, 215));

// Resets the checkboxes.
DebugUtil.debug("Resetting the Automatic Repairs progress checkboxes...");
for (JCheckBox checkbox : progressCheckboxes) {
checkbox.setEnabled(true);
checkbox.setSelected(false);
}
return;
}

// Checks if the operating system is outdated.
DebugUtil.debug("Checking if the operating system is outdated...");
if (RepairKit.isOutdatedOperatingSystem()) {
Expand All @@ -150,52 +217,94 @@ private void runAutomaticRepairs() {
}

// Creates a restore point.
runButton.setText("Creating Restore Point");
createRestorePoint();
runButton.setText("Running Repairs...");

// Deletes system policies.
deleteSystemPolicies();
SwingUtilities.invokeLater(() -> progressCheckboxes[0].setSelected(true));
if (deleteSystemPolicies) {
deleteSystemPolicies();
SwingUtilities.invokeLater(() -> progressCheckboxes[0].setSelected(true));
}

// Creates tasks for the executor.
List<Runnable> tasks = List.of(
() -> {
// Runs registry tweaks.
runRegistryTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[1].setSelected(true));
if (runRegistryTweaks) {
// Runs registry tweaks.
runRegistryTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[1].setSelected(true));
}
},

() -> {
if (runSystemTweaks) {
// Runs system tweaks.
runSystemTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[2].setSelected(true));
}
},

() -> {
if (runFeaturesTweaks) {
// Runs features tweaks.
runFeaturesTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[3].setSelected(true));
}

if (runCapabilitiesTweaks) {
// Runs capabilities tweaks.
runCapabilitiesTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[4].setSelected(true));
}

if (repairDiskIssues) {
// Repairs disk issues.
// This has to be done after the DISM commands in the above tweaks.
repairDiskIssues();
SwingUtilities.invokeLater(() -> progressCheckboxes[8].setSelected(true));
}
},

() -> {
if (runServicesTweaks) {
runServicesTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[5].setSelected(true));
}
},

() -> {
// Runs system tweaks.
runSystemTweaks();
runFeaturesTweaks();
runCapabilitiesTweaks();
runServicesTweaks();
SwingUtilities.invokeLater(() -> progressCheckboxes[2].setSelected(true));

// Repairs disk issues.
// This has to be done after the DISM commands in the system tweaks.
repairDiskIssues();
SwingUtilities.invokeLater(() -> progressCheckboxes[5].setSelected(true));
if (removeJunkFiles) {
// Removes junk files.
JunkFileUtil.removeJunkFiles();
SwingUtilities.invokeLater(() -> progressCheckboxes[6].setSelected(true));
}
},

() -> {
// Removes junk files.
JunkFileUtil.removeJunkFiles();
SwingUtilities.invokeLater(() -> progressCheckboxes[3].setSelected(true));
if (removeBloatware) {
// Removes bloatware if the system is not in safe mode.
if (!RepairKit.isSafeMode()) {
removeBloatware();
}
SwingUtilities.invokeLater(() -> progressCheckboxes[7].setSelected(true));
}
},

() -> {
// Removes bloatware if the system is not in safe mode.
if (!RepairKit.isSafeMode()) {
removeBloatware();
if (scanForMalware) {
// Scans the system for malware.
scanForMalware();
SwingUtilities.invokeLater(() -> progressCheckboxes[9].setSelected(true));
}
SwingUtilities.invokeLater(() -> progressCheckboxes[4].setSelected(true));
},

() -> {
// Scans the system for malware.
scanForMalware();
SwingUtilities.invokeLater(() -> progressCheckboxes[6].setSelected(true));
if (updateOutdatedPrograms) {
// Updates outdated programs.
updateOutdatedPrograms();
SwingUtilities.invokeLater(() -> progressCheckboxes[10].setSelected(true));
}
}
);

Expand All @@ -212,12 +321,14 @@ private void runAutomaticRepairs() {

// Resets the run button.
DebugUtil.debug("Resetting the run button...");
runButton.setText("Run Automatic Repairs");
runButton.setEnabled(true);
runButton.setBackground(new Color(0, 120, 215));

// Resets the checkboxes.
DebugUtil.debug("Resetting the Automatic Repairs progress checkboxes...");
for (JCheckBox checkbox : progressCheckboxes) {
checkbox.setEnabled(true);
checkbox.setSelected(false);
}
} catch (HeadlessException ex) {
Expand Down Expand Up @@ -547,7 +658,8 @@ private static void scanForMalware() {
boolean defenderRunning = ProcessUtil.isProcessRunning("MsMpEng.exe");

// Scan with Windows Defender if enabled and running.
if (defenderRunning && defenderConfig != null
if (defenderRunning
&& defenderConfig != null
&& defenderConfig.get("enabled") != null
&& defenderConfig.get("enabled").equals(Boolean.TRUE)) {
scanWithWindowsDefender(defenderConfig);
Expand Down Expand Up @@ -822,4 +934,18 @@ private static void scanWithSophos() {

DebugUtil.debug("Completed Sophos Scan.");
}

/**
* Updates outdated programs using WinGet.
*/
private static void updateOutdatedPrograms() {
DebugUtil.debug("Updating outdated programs...");

// Updates outdated programs using Winget.
// CommandUtil.getCommandOutput("winget upgrade --all --disable-interactivity --silent"
// + " --accept-package-agreements --accept-source-agreements", true, false);
WinGetUtil.updateAllPrograms();

DebugUtil.debug("Completed updating outdated programs.");
}
}
Loading

0 comments on commit ece1acc

Please sign in to comment.