如何以编程方式写入Powershell中的当前提示行

时间:2010-02-04 09:47:27

标签: powershell

是否可以将文本发送到当前提示行?如下所示:

PS[10]> Get-Location
c:/
PS[11]> Write-PromptLine "This text has been written by Powershell"
PS[12]> This text has been written by Powershell|
# | denotes the caret

1 个答案:

答案 0 :(得分:5)

您可以使用SendKeys.SendWait方法:

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("This text has been written by Powershell")