我想使用 C/C++/Powershell 将命令/powershell 窗口的屏幕缓冲区复制到文本文件中。
有什么办法吗?
使用主机控制台 API:-
$rec = new-object System.Management.Automation.Host.Rectangle 0,0,($host.ui.rawui.BufferSize.Width - 1),$host.ui.rawui.CursorPosition.Y
$buffer = $host.ui.rawui.GetBufferContents($rec)
使用>> 或 | 将缓冲区写入文件
使用 Start-Transcript
和 Stop-Transcript
怎么样?
Technet:创建您在 Windows PowerShell 中执行的操作的脚本