首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在命令窗口重定向以亲和力启动的应用程序的输出?

如何在命令窗口重定向以亲和力启动的应用程序的输出?
EN

Stack Overflow用户
提问于 2019-12-13 06:05:24
回答 1查看 196关注 0票数 0

以下命令在新命令窗口中启动C++应用程序,并将进程亲和性设置为0xF。

代码语言:javascript
复制
start /affinity F test.ext arg1 arg2

但上述命令会打开一个新的命令窗口,并在test.exe结束时立即关闭。我尝试执行以下命令以获取输出,但它什么也做不到。

代码语言:javascript
复制
start /affinity F test.ext arg1 arg2 ^> out.txt

如果您知道如何在powershell上执行此操作,我将不胜感激。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2019-12-13 11:14:57

About Redirection

PowerShell重定向运算符如下所示,其中n表示流编号。如果未指定流,则成功流(1)为默认值。

操作员描述

语法

代码语言:javascript
复制
>           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的文件

代码语言:javascript
复制
# 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

Quoting specifics

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59313361

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档