如何从命令行启动PowerShell(不是脚本)

23

我对PowerShell还不熟悉,目前遇到一个看似简单的问题—我想通过命令行启动PowerShell窗口。

如果我在命令行中输入powershell或者start powershell,会在命令行界面内获得一个PowerShell实例,也就是通常的黑底白字的界面。但我想要的是典型的PowerShell界面—蓝底白字的界面?我正在运行安装了PowerShell 2.0的Windows XP系统。

3个回答

33

如果你在Windows资源管理器中前往 C:\Windows\system32\Windowspowershell\v1.0(对于x64机器,在C:\Windows\syswow64\Windowspowershell\v1.0),并双击 powershell.exe,你会发现它以黑色背景打开了PowerShell。当从开始菜单打开时,PowerShell控制台显示为蓝色,因为可以独立设置指向powershell.exe的快捷方式的控制台属性。

要设置默认选项、字体、颜色和布局,请打开PowerShell控制台,键入 Alt-Space,然后选择“Defaults”菜单选项。

从cmd.exe运行 start powershell 应该会使用默认设置启动一个新的控制台。


15

设置默认的控制台颜色和字体:

http://poshcode.org/2220
来源:《Windows PowerShell Cookbook (O'Reilly)》
作者:Lee Holmes (http://www.leeholmes.com/guide)

Set-StrictMode -Version Latest

Push-Location
Set-Location HKCU:\Console
New-Item '.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe'
Set-Location '.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe'

New-ItemProperty . ColorTable00 -type DWORD -value 0x00562401
New-ItemProperty . ColorTable07 -type DWORD -value 0x00f0edee
New-ItemProperty . FaceName -type STRING -value "Lucida Console"
New-ItemProperty . FontFamily -type DWORD -value 0x00000036
New-ItemProperty . FontSize -type DWORD -value 0x000c0000
New-ItemProperty . FontWeight -type DWORD -value 0x00000190
New-ItemProperty . HistoryNoDup -type DWORD -value 0x00000000
New-ItemProperty . QuickEdit -type DWORD -value 0x00000001
New-ItemProperty . ScreenBufferSize -type DWORD -value 0x0bb80078
New-ItemProperty . WindowSize -type DWORD -value 0x00320078
Pop-Location

11

颜色和窗口大小由快捷方式LNK文件定义。我认为我找到了一种可以满足你需求的方法,请尝试以下操作:

explorer.exe "Windows PowerShell.lnk"

LNK文件在“所有用户”开始菜单中,其位置取决于您是否使用XP或Windows 7。 在Windows 7中,LNK文件在此处:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell

1
太棒了!如果你右击并选择“属性”,你可以看到.lnk文件是如何存储所有属性的。 - Farzher

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接