Powershell open window (from Java.Runtime.exec)

风流意气都作罢 提交于 2019-12-11 07:43:04

问题


simple Question:

i want to call the powershell with some commands from java. But the Problem is that no Window appears. i want that the window with the Powershell appears.

String[] str= {
"powershell.exe", "-NoExit", "-Command", "echo", "hallo"
}

[...]

Runtime.getRuntime().exec(str);

[...]

回答1:


I was able to do it like this:

String[] str= { "cmd",  "/c", "start", "powershell.exe", "-NoExit", "-Command", "echo", "hallo" };


来源:https://stackoverflow.com/questions/25530774/powershell-open-window-from-java-runtime-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!