繁体   English   中英

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

[英]How to launch PowerShell (not a script) from the command line

我是PowerShell的新手,我正在努力解决我认为应该是一个简单的操作 - 我试图从命令行启动一个PowesShell窗口。

如果我启动一个命令行实例并键入powershellstart powershell ,我将在命令行界面中获得一个PowerShell实例,即带有白色文本的典型黑色背景。 我想要的是典型的PowerShell界面启动蓝色背景白色文本? 我正在运行安装了PowerShell 2.0的Windows XP。

如果在Windows资源管理器中转到C:\\Windows\\system32\\Windowspowershell\\v1.0 (以及x64计算机上的C:\\Windows\\syswow64\\Windowspowershell\\v1.0 )并双击powershell.exe您将看到它打开PowerShell与黑色背景。 从开始菜单打开时,PowerShell控制台显示为蓝色,因为可以独立于默认属性设置powershell.exe快捷方式的控制台属性。

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

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

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

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

颜色和窗口大小由快捷方式LNK文件定义。 我想我找到了一种可以做你需要的方法,试试这个:

explorer.exe "Windows PowerShell.lnk"

LNK文件位于所有用户开始菜单中,根据您的XP或Windows 7,它位于不同的位置。在7中,LNK文件位于:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM