PowerShell から Java プログラムを開始し、結果をコンソールに出力したいと考えています。
この質問の指示に従いました: Start-Process で標準出力とエラーをキャプチャする
しかし、私にとっては、これは期待どおりに機能していません。私が間違っていることは何ですか?
これはスクリプトです:
$psi = New-object System.Diagnostics.ProcessStartInfo
$psi.CreateNoWindow = $true
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.FileName = 'java.exe'
$psi.Arguments = @("-jar","tools\compiler.jar","--compilation_level", "ADVANCED_OPTIMIZATIONS", "--js", $BuildFile, "--js_output_file", $BuildMinFile)
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $psi
$process.Start() | Out-Null
$process.WaitForExit()
$output = $process.StandardOutput.ReadToEnd()
$output
変数は常に空です($output
もちろん、コンソールには何も表示されません)。