2014-08-27 83 views
1

simple問題:Powershell打開窗口(來自Java.Runtime.exec)

我想用java的一些命令調用powershell。但問題是沒有出現窗口。我希望帶有Powershell的窗口出現。

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

[...] 

Runtime.getRuntime().exec(str); 

[...] 

回答

1

我能夠做到這一點是這樣的:

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

是的,它的工作原理。謝謝Mikkel K. :) – user3875103 2014-08-27 18:31:16

+0

在這種情況下,你能接受答案嗎? :) – 2014-08-28 08:26:20

+0

最初'cmd/c' - 是我一直缺乏..)) – 2017-06-16 14:34:56