【发布时间】:2020-03-03 04:19:04
【问题描述】:
我正在尝试通过 java 代码启动一个 Steam 应用程序。
首先,我得想办法用cmd打开它,这很简单,我只需要输入start steam://rungameid/xxx
现在,我需要我的 java 程序来打开应用程序
这是我迄今为止尝试过的。
Runtime.getRuntime().exec("start steam://rungameid/xxx");
和
new ProcessBuilder("start", "steam://rungameid/xxx").start()
它们都导致了 IOException
Exception in thread "main" java.io.IOException: Cannot run program "start": CreateProcess error=2, The system cannot find the file specified
我不知道如何解决这个问题,所以我需要帮助。
【问题讨论】:
-
@arundeepchohan 'start' 是内置命令,不是文件。
-
Runtime.getRuntime().exec("cmd.exe /C start steam://rungameid/xxx"");
-
试试吧。
-
它正在工作,将其发布为答案,我会接受它。
标签: java runtime runtime.exec