【发布时间】:2012-02-16 18:50:05
【问题描述】:
我有一个启动 PowerShell 脚本的批处理文件。
批处理文件:
START Powershell -executionpolicy RemoteSigned -noexit -file "MyScript.ps1"
MyScript.ps1:
Write-Output "Hello World!"
它工作正常,但有一个例外。窗口的外观就像旧的 cmd.exe(黑色背景)而不是 PowerShell(蓝色背景)。
如果我从批处理文件启动它,如何获得真正的 PowerShell 窗口?
谢谢。
【问题讨论】:
-
感谢到目前为止所有发帖的人。我真的不在乎背景是蓝色还是黑色。我想知道为什么会发生这种情况。如果我这样做:启动记事本然后记事本正常启动并且周围没有 cmd.exe 的痕迹。记事本看起来就像我从快捷方式启动它一样。为什么它与 PowerShell 不同?如果我从批处理文件与从快捷方式启动它,为什么会有所不同?我有点喜欢在新的 PowerShell 中右键单击进行粘贴。谢谢。
-
此外,默认情况下,命令提示符仅保留 300 行,而 PowerShell 保留更多行,因此如果您使用
start powershell -noexit -executionpolicy unrestricted -file "PowerShell script.ps1"之类的内容,则需要在 PowerShell 中实际打开它,而不是命令提示符,这样您就可以看到脚本的完整历史记录。
标签: powershell command-line batch-file