0

the following command starts the C++ application in new command window with process affinity set to 0xF.

start /affinity F test.ext arg1 arg2

But the above command opens a new cmd window and closes immediately when test.exe ends. I tried the following to get output but it doesn't do anything.

start /affinity F test.ext arg1 arg2 ^> out.txt

I appreciate if you know how to do this on powershell.

Thanks

RedFox
  • 1,158
  • 2
  • 15
  • 28

1 Answers1

0

About Redirection

The PowerShell redirection operators are as follows, where n represents the stream number. The Success stream ( 1 ) is the default if no stream is specified.

Operator Description
Syntax

>           Send specified stream to a file.                        n>
>>          Append specified stream to a file.                      n>>
>&1         Redirects the specified stream to the Success stream.   n>&1


# Examples
# Example 1: Redirect errors and output to a file

dir 'C:\', 'fakepath' 2>&1 > .\dir.log

This example runs dir on one item that will succeed, and one that will error.

It uses 2>&1 to redirect the Error stream to the Success stream, and > to send the resultant Success stream to a file called dir.log

# Example 2: Send all Success stream data to a file

.\script.ps1 > script.log

This command sends all Success stream data to a file called script.log

Also, a possible duplicate of the following

How to pipe all output of .exe execution in Powershell?

How to redirect the output of a PowerShell to a file during its execution

See also

Running external commands, can or will require special consideration.

PowerShell: Running Executables

Solve Problems with External Command Lines in PowerShell

Top 5 tips for running external commands in Powershell

Using Windows PowerShell to run old command line tools (and their weirdest parameters)

Execution of external commands in PowerShell done right

Quoting specifics

postanote
  • 15,138
  • 2
  • 14
  • 25