Inserer mdp (java+dos)

Fermé
hjbb - Modifié par hjbb le 8/04/2012 à 16:11
j'ai écrit ce code, pour exécuter des commandes dos avec java, mais le pb est de ne pas etre capable d'inserer mdp

code:

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 :
A voir également: