我正在尝试使用 PowerShell(版本 2)Start-Process
并重命名新启动的窗口标题。我有以下工作正常的代码片段,它启动一个新的 PowerShell 窗口并跟踪日志($c
包含要跟踪的日志文件):-
Start-Process powershell.exe -Argument "Get-Content", $c, "-wait"
我不确定如何包含以下内容以便可以更改新启动的窗口标题。
$host.ui.RawUI.WindowTitle = 'New window title rename example text'
干杯。
最佳答案
“肮脏”的解决方案是:
start-process powershell.exe -argument "`$host.ui.RawUI.WindowTitle = 'New window title rename example text'; get-content -Path $c -wait"
我建议为您的命令创建一个脚本并使用参数进行输入。
无题2.ps1
param($c)
$host.ui.RawUI.WindowTitle = 'New window title rename example text'
Get-Content -Path $c -Wait
脚本
$script = Get-Item ".\Desktop\Untitled2.ps1"
$c = Get-Item ".\Desktop\t.txt"
Start-Process powershell.exe -ArgumentList "-File $($script.FullName) -c $($c.FullName)"
关于PowerShell - 如何使用 'Start-Process' 并重命名新启动的窗口标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27607323/