PowerShell 바로 가기에서 "기본" 색상으로 powershell.exe를 시작하려면 어떻게 해야 합니까?
미리 설치된 바로 가기 중 하나에서 시작하면 PowerShell 창의 멋진 파란색이 마음에 듭니다.그러나 수동으로 powershell.exe를 실행하면 이러한 색상이 표시되지 않고 검정/흰색이 표시됩니다. :(
바로 가기(.lnk) 파일에 기본 설정이 설정되어 있기 때문입니다.

탐색기 컨텍스트 메뉴에 "PowerShell Prompt Here" 항목이 있는데, 일반적인 바로 가기와 동일한 좋은 색상을 사용하여 PowerShell을 실행했으면 합니다. 검은색은 썩고, 다른 색상의 창이 있으면 혼란스럽습니다(특히 일부 올드스쿨 명령 창이 자주 열려 검은색이기도 합니다!).
지금까지 이 설정을 시도하면서 두 가지 문제점을 발견했습니다.
- PowerShell 내에서 색상을 설정하면 특정 값(ConsoleColor enum)만 허용되는 것으로 보이며, 이 값 중 어떤 값도 기본 바로 가기의 값과 일치하지 않습니다.
- PS 프로파일 내에서 색상을 설정하면 나중에 작성된 텍스트만 새 배경 색상을 나타냅니다."cls"를 추가하면 시작할 때 원래 색상이 역겨운 플래시가 발생합니다.
바로 가기와 동일한 설정을 사용하는 명령줄(즉, 레지스트리에 탐색기 컨텍스트 메뉴 항목으로 포함할 수 있음)에서 PowerShell을 시작할 수 있는 방법이 있습니까?
$profile로 표시된 프로필 스크립트를 편집하고 원하는 색상을 직접 설정합니다.
# set regular console colors
[console]::backgroundcolor = "darkmagenta"
[console]::foregroundcolor = "darkyellow"
# set special colors
$p = $host.privatedata
$p.ErrorForegroundColor = "Red"
$p.ErrorBackgroundColor = "Black"
$p.WarningForegroundColor = "Yellow"
$p.WarningBackgroundColor = "Black"
$p.DebugForegroundColor = "Yellow"
$p.DebugBackgroundColor = "Black"
$p.VerboseForegroundColor = "Yellow"
$p.VerboseBackgroundColor = "Black"
$p.ProgressForegroundColor = "Yellow"
$p.ProgressBackgroundColor = "DarkCyan"
# clear screen
clear-host
여기에 정말 쉬운 방법이 있습니다.
1. 추가.PATHEXT 변수에 LNK를 적용합니다.
시작 -> "sysdm.cpl" 실행 -> 고급 -> 환경 변수
시스템 변수에서 아래로 스크롤하고 PATHEXT를 두 번 클릭합니다.
아래 그림과 같이 .LNK를 추가합니다.

2 기본 "Windows Powershell.lnk" 복사
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" "C:\Windows\System32\powershell.lnk"
3. 실행 프롬프트에서 "powershell"을 입력하면 기본 콘솔 색상/구성이 나타납니다.
C:에서 .lnk를 추가로 사용자 정의할 수 있습니다.\Windows\32번 시스템이 마음에 듭니다.
허용 가능한 확장명 목록에 .lnk를 추가했기 때문에 이 작업은 사용할 수 있습니다. 그리고 c:\windows\system32는 기본적으로 검색 경로(PATH 시스템 변수)의 첫 번째 항목입니다.
cmd.exe를 통해 콘솔을 시작하는 경우에는 콘솔을 사용자 지정하지 않습니다.
4. To make this work from the "Run Powershell Here" context menu, save this as a .reg file and import it:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\PowerShellHere\command]
@="C:\\WINDOWS\\system32\\cmd.exe /c start powershell -NoExit \"cd '%1';(get-host).ui.rawui.windowtitle = 'Oompa Loompa'\""
[HKEY_CLASSES_ROOT\Directory\shell\PowerShellHere\command]
@="C:\\WINDOWS\\system32\\cmd.exe /c start powershell -NoExit \"cd '%1';(get-host).ui.rawui.windowtitle = 'Oompa Loompa'\""
I am using cmd.exe to call "start" which will launch the powershell.lnk and pass the current working directory as an argument. Doesn't seem to work from the address bar yet. I should have gone home 45mins ago, but your problem was fun to solve! :)
Bonus Points: You can thread the commands sent to Powershell. So, if you are looking to modify the Powershell console's title attribute:
\"cd '%1';(get-host).ui.rawui.windowtitle = 'Oompa Loompa'"
Simply add a semicolon between commands.
Happy shelling
I found it very useful to use concfg tool and scoop to install colors and fonts for Powershell:
Install scoop:
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')Install concfg:
scoop install concfgInstall Solarized theme:
concfg import solarized
That's it, thanks to the authors!
The correct way to do this is with the Registry
cd hkcu:/console
$0 = '%systemroot%_system32_windowspowershell_v1.0_powershell.exe'
ni $0 -f
sp $0 ColorTable00 0x00562401
sp $0 ColorTable07 0x00f0edee
Click the system menu (PowerShell icon in the top-left of the window) and click Defaults. You can change the default colors here and it will be respected by the PowerShell Prompt Here command.
From: https://superuser.com/a/523017/109736
- 달려.
regedit레지스트리 편집기를 여는 명령 - 추적하다
HKEY_CURRENT_USER > CONSOLE만일의 경우를 대비해 내보내기를 통해 전체 폴더 백업 - Delete the folder
Restart your Powershell, the color scheme must have reset to defaults.
Note: If you have any other settings related to PowerShell (or Command Prompt, Git Bash etc) which you might want to keep, please further explore Console Folder to delete appropriate keys
This was my solution (setting the colors in a script that launches as system). May be more than you need (see my own answer):
Based on @rex-hardin excellent answer, I improved the regedit content here to add an icon, and use the PowerShell native arguments to start in the right path.
The context-menu is enabled when right-clicking on a directory background, and when right-clicking directly on a directory icon.
Of course, we also run a console with blue background exactly like the default one.
1. 추가".LNK" 까지 확장.%PATHEXT%환경변수
이것은 시스템이 다음과 같이 파일을 실행할 수 있게 해줍니다..lnk확장명(바로 가기의 숨겨진 확장명)
2. 시스템32에 기본 PowerShell 바로 가기 링크를 다음과 같이 복사합니다.powershell파일
이것은 허용합니다.powershell명령을 실행하여 바로 가기를 시작합니다.system32폴더(에 있음)%PATH%)
탐색기(copy+rename) 또는 아래 명령줄을 사용합니다.
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" "C:\Windows\System32\powershell.lnk"
3. 아래 코드를 a에 추가합니다.powershell_here.reg파일을 작성하고 실행합니다.
powershell_here.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\directory\background\shell\PowerShell]
@="PowerShell Here"
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
[HKEY_CLASSES_ROOT\directory\background\shell\PowerShell\command]
@="cmd.exe /c start powershell -NoExit -NoProfile -Command Set-Location -LiteralPath '%V'"
[HKEY_CLASSES_ROOT\directory\shell\PowerShell]
@="PowerShell here"
"Icon"="%SystemRoot%\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"
[HKEY_CLASSES_ROOT\directory\shell\PowerShell\command]
@="cmd.exe /c start powershell -NoExit -NoProfile -Command Set-Location -LiteralPath '%L'"
Windows 7 Pro 64비트의 탐색기 또는 Total Commander 또는 Double Commander에서 현재 폴더에 있는 기본 파란색과 흰색으로 파워셸을 실행합니다.
- 별메뉴 -> 검색 PowerShell 링크 -> 우클릭 -> 속성 -> 바로가기 탭(기본적으로 열리는 것) -> 수정 시작 : -> %CD%
ps.bat라는 이름의 배치 파일을 시스템 PATH에 있는 폴더 어딘가에 생성합니다(이러한 폴더가 없으면 C:\run\cli라고 하고 PATH 시스템 환경 변수에 추가합니다).이 배치 파일에는 다음 명령이 포함되어야 합니다.
시작 " " "C:\ProgramData\Microsoft\"Windows\시작 메뉴\프로그램\부속품\Windows PowerShell\Windows PowerShell.lnk"
바로 그겁니다.이제 현재 폴더가 표시된 탐색기의 경로 표시줄이나 Total Commander 또는 Double Commander의 명령줄 상자에 ps를 입력하면 됩니다.
Windows 10에서는 시작 메뉴에서 PowerShell 바로 가기를 수정할 필요가 없으며 위의 ps.bat 파일에는 다음 명령만 포함될 수 있습니다.
start %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
언급URL : https://stackoverflow.com/questions/13690223/how-can-i-launch-powershell-exe-with-the-default-colours-from-the-powershell-s
'programing' 카테고리의 다른 글
| Java 프로그램에서 PowerShell 명령 실행 (0) | 2023.10.31 |
|---|---|
| Woocommerce 후크에서 함수 제거 (0) | 2023.10.31 |
| 페이지를 스크롤하지 않고 위치 해시를 제거하려면 어떻게 해야 합니까? (0) | 2023.10.31 |
| C에서 ENUM을 함수 인수로 전달하는 방법 (0) | 2023.10.31 |
| PowerShell을 사용하여 클립보드로 파이프 출력 (0) | 2023.10.31 |

