java - command works in Windows cmd but fails with Runtime.getRuntime.exec() -
windows 7 cmd has no trouble executing ping -n 5 127.0.0.1 > nul. also, runtime.getruntime.exec(new string[]{"ping", "-n", "5", "127.0.0.1"}) works fine.
but runtime.getruntime.exec(new string[]{"ping", "-n", "5", "127.0.0.1", ">", "nul"}) fails bad parameter >. why?
i'm using java7 in java6 mode.
the > redirection not part of ping command, part of cmd itself. when exec() sees > tries feed ping argument.
to same functionality, read (and ignore) data inputstream process exec return value.
Comments
Post a Comment