Skip to main content
 首页 » 编程设计

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

2025年05月04日130dflying

是否可以向当前提示行发送文本?类似于以下内容:

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 

请您参考如下方法:

您可以使用 SendKeys.SendWait方法:

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