inserer mot de passe (ms-dos)
j'ai écrit ce code, pour exécuter des commandes ms-dos avec java, mais le pb est de ne pas etre capable d'inserer le mot de pass
Code:
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
| package javaapplication17;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
public class JavaApplication17 {
public static void main(String[] args) throws IOException {
try{
String ch ="runas /user:hp \"netstat -b\"";
System.out.println(ch);
Process p = Runtime.getRuntime().exec(ch);
// read the standard output of the command
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
System.out.println("Here is the standard output of the command:\n");
String s;
String result = "";
while ((s = stdInput.readLine()) != null) {
result =result + s + "\n";
}
System.out.println(result);
stdInput.close();
}catch(Exception e) {System.out.println("zzzzz"+e);}
}
} |
resultat:
runas /user:hp "netstat -b"
Here is the standard output of the command:
Entrez le mot de passe de hp :