如何使用 Kotlin 运行 Powershell 脚本?
我试图移植一些我在 StackOverflow 上找到的 Java 代码,但我无法让它工作。我还尝试了以下方法:
Runtime.getRuntime().exec("powershell.exe [path to file]")
但这也不起作用。
在 Kotlin 中执行此操作的最简单方法是什么?
最佳答案
请添加“-File”参数,例如脚本应该是这样的:
Runtime.getRuntime().exec("powershell.exe -File d:\\my-script.ps1")
关于powershell - 如何从 Kotlin 运行 PowerShell 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52684385/