Use jobs for this:
Start-Job -ScriptBlock {
& java -jar MyProgram.jar >console.out 2>console.err
}
Another option would be Start-Process
:
Start-Process java -ArgumentList '-jar', 'MyProgram.jar' `
-RedirectStandardOutput '.\console.out' -RedirectStandardError '.\console.err'
More Related Contents:
- Is there a way to find the length of a string in Batch/PowerShell Script/VBScript? [closed]
- Batch file v PowerShell script
- How to delete subfolders and Files but not parent Folder in windows using Script? [closed]
- Powershell: null file always generated (output of Compare-Object)
- Setting Windows PowerShell environment variables
- How to run a PowerShell script without displaying a window?
- PowerShell difference between Write-Host and Write-Output?
- Running PowerShell in Task Scheduler
- How can I uninstall an application using PowerShell?
- FORFILES date -after- (date calc in cmd file)
- How to run a PowerShell script within a Windows batch file
- How do I get the current username in Windows PowerShell?
- Windows PowerShell: changing the command prompt
- Running cURL on 64 bit Windows
- How to stop a PowerShell script on the first error?
- Difference between $? and $LastExitCode in PowerShell
- Decode PowerShell output possibly containing non-ASCII Unicode characters into a Python string
- “Firebase cannot be loading because running scripts is disabled on this system”, VSCode on Windows
- Powershell’ is not recognized as an internal or external command, operable program or batch file
- Can I send some text to the STDIN of an active process under Windows?
- Cannot remove item, The Directory is not empty
- How to create a Run As Administrator shortcut using Powershell
- How to output something in PowerShell
- Cannot run Maven using `mvn -D` argument within Microsoft Powershell, but works in Command Prompt
- Alternative to Win32_Product?
- What’s the environment variable for the path to the desktop?
- Powershell script does not run via Scheduled Tasks
- MSOnline can’t be imported on PowerShell (Connect-MsolService error)
- powershell : changing the culture of current session
- IE Enable/Disable Proxy Settings via Registry