以下命令在新命令窗口中启动C++应用程序,并将进程亲和性设置为0xF。
start /affinity F test.ext arg1 arg2但上述命令会打开一个新的命令窗口,并在test.exe结束时立即关闭。我尝试执行以下命令以获取输出,但它什么也做不到。
start /affinity F test.ext arg1 arg2 ^> out.txt如果您知道如何在powershell上执行此操作,我将不胜感激。
谢谢
发布于 2019-12-13 11:14:57
PowerShell重定向运算符如下所示,其中n表示流编号。如果未指定流,则成功流(1)为默认值。
操作员描述
语法
> 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此示例在一个将成功的项目和一个将出错的项目上运行目录。
它使用2>&1将错误流重定向到成功流,并使用>将结果成功流重定向到名为dir.log的文件
# Example 2: Send all Success stream data to a file
.\script.ps1 > script.log此命令将所有成功流数据发送到名为script.log的文件
还可能是以下的副本
How to pipe all output of .exe execution in Powershell?
How to redirect the output of a PowerShell to a file during its execution
另请参阅
运行外部命令的
可能需要或将需要特殊考虑。
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
https://stackoverflow.com/questions/59313361
复制相似问题