views:

185

answers:

1

Hi, I´m developing a netsh thread that keeps netsh open so I just have to call it once.

Everything worked fine until I tried my app in a Spanish-Windows enviroment...

netsh tells me that it can´t find the interfaces I´m specifying on the commands and I´m pretty sure that the cause of this is because some of these interfaces names have accents...

So, I´m guessing this is a encoding problem...

my code looks like this:

private netshOutStream =  new BufferedOutputStream(netshProcess.getOutputStream());
private PrintWriter netshWriter = new PrintWriter(netshOutStream, true);
Scanner fi = new Scanner(netshProcess.getInputStream());

public void executeCommand(String command) {
        System.out.println("Executing: " + command);
        String str = "";
        netshWriter.println(command);
        fi.skip("\\s*");
        str = fi.nextLine();
        System.out.println(str);
}

Can anyone help me?

Thank you!!!

A: 

Try the other constructor and give him the right character set for the process:

public OutputStreamWriter(OutputStream out, String charsetName)

Can you give the logging output of what netsh receives ?

mhaller
Hi... !!!For example:"Executing: int ip set address "Conexión de área local 2" static 6.4.4.4 255.0.0.0"and str value is:"Interfaz especificada no v lida Conexión de área local 2."which means: invalid interface, like that interface didn´t exists, and I´m 100% sure it exits, look at a ipconfig output of my machine:Adaptador Ethernet Conexión de área local 2 : Sufijo de conexión específica DNS : Dirección IP. . . . . . . . . . . : 5.4.4.4 Máscara de subred . . . . . . . . : 255.0.0.0 Puerta de enlace predeterminada :
Valentina