【发布时间】:2021-10-27 14:26:42
【问题描述】:
我想使用命令从 java 应用程序启动 powershell 窗口。 Cmd 被我们的公司政策阻止。
我试过了
new ProcessBuilder("powershell.exe", "start \"servicemix\" powershell -noexit -command \"dir\"").start();
但是它不会打开新窗口。我设法打开powershell窗口的唯一方法是使用
Desktop.getDesktop().open(new File("full/path/to/powershell"));
但我还没有想出如何在该窗口中自动运行命令。
操作系统:windows
【问题讨论】:
-
你确定公司政策允许你想做什么?
-
不确定,但是我可以在后台在powershell中执行命令,只是无法打开powershell窗口。
标签: java windows powershell