Powershell Start-process Java PassThru

时间:2016-06-09 21:45:06

标签: java powershell

Windows Power shell启动后无法获取java进程详细信息。它适用于“记事本”,但不适用于java。

工作记事本cmd:

  PS > $apmax=Start-Process notepad "abc.txt" -PassThru

失败的java:

PS > $apmax=Start-Process java "-jar ApMaxProvMngr-1.0.jar" -PassThru
Start-Process : This command cannot be run completely because the system cannot find all the information 
required.
At line:1 char:8
+ $apmax=Start-Process java "-jar ApMaxProvMngr-1.0.jar" -PassThru
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

我在这里错过了一些东西吗?

1 个答案:

答案 0 :(得分:0)

  1. 使用显式'ArgumentList'参数(请参阅docs);
  2. 分别传递多个参数。

    $apmax=Start-Process java -ArgumentList '-jar','ApMaxProvMngr-1.0.jar' -PassThru
    
相关问题