-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwifiscan.java
More file actions
30 lines (25 loc) · 1.15 KB
/
Copy pathwifiscan.java
File metadata and controls
30 lines (25 loc) · 1.15 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CmdExecutor {
public static void main(String[] args) {
try {
// 1. Changer la couleur de la console (CMD) en vert avec 'color a'
ProcessBuilder colorCmd = new ProcessBuilder("cmd.exe", "/c", "color a");
colorCmd.inheritIO().start().waitFor(); // Exécuter et attendre la fin de la commande
// 2. Exécuter 'netsh wlan show profile' pour afficher les profils Wi-Fi
ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", "netsh wlan show profile");
Process process = pb.start();
// 3. Lire la sortie de la commande et l'afficher
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
// Attendre la fin de l'exécution du processus
process.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}