How it happens that Powershell executed with "run" and with pinned icon has different settings?

5

3

On my Windows 7, if i run a powershell via "Win+R", "powershell" it will start with white text on black background and settings are affected via [HKEY_CURRENT_USER\Colors]. For example, i can easily change the default "red" color to be less bright:

enter image description here

But if i pin this powershell to Windows 7 superbar and start it by clicking superbar icon, it will display some mad blue-and-white colors that i can't change O_O:

enter image description here

Why such difference and is it any way to configure colors of pinned powershell same way i can configure powrshell that is started via "run" command.

grigoryvp

Posted 2012-12-22T10:23:12.370

Reputation: 957

if you run "$profile" in each window, does it display the same profile? or different? – Logman – 2012-12-22T14:12:08.517

@Logman It was the first thing i have checked. Exactly same profile. You can check it for yourself - any Windows 7 do as i described :( – grigoryvp – 2012-12-22T14:21:13.697

when I do it, the font color is almost or a perfect match. BUT the background color is different: one black and the other dark blue. – Logman – 2012-12-22T15:05:36.077

Answers

14

TL;DR

  1. Run powershell.exe
  2. ALT-SPACE -> Properties
  3. Change your settings as desired.
  4. OK

powershell.exe is a console program. When a console program runs, Windows configures the console by looking in a bunch of locations.

First it looks at the shortcut (.LNK file) you launched. That's what you'll typically see in the start menu, on the desktop, in the taskbar. If you RClick on the shortcut and select Properties, you'll see a bunch of these options there.

For any options that aren't specified in the shortcut (or if you launched the .EXE directly, without a shortcut), Windows will look in the registry.

I couldn't find a comprehensive list of registry keys involved, but here are the ones I know about:

HKEY_CURRENT_USER\Console
HKEY_CURRENT_USER\Software\Microsoft\Command Processor
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor

But wait, there's more!

When you open the System menu on a console window you see both "Properties" and "Defaults".

Defaults modifies one of the above registry keys.

The properties apply to the currently open console window and the shortcut that launched it. If you didn't use a shortcut because you opened the .EXE directly, it goes to a special registry key, instead, like:

HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe

But that's not all!

Console programs have the ability to modify their own colors. For example, in CMD you can do:

C:\>color f0

And in PowerShell:

PS> $Host.UI.RawUI.BackgroundColor = 7

These settings are not persisted in any way.

Jay Bazuzi

Posted 2012-12-22T10:23:12.370

Reputation: 3 780

Along with the group of 3 registry keys listed above, HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe also affects Powershell's settings. For example, you can set the background color throughout Powershell by creating a DWord named ColorTable00 with a hex color value of your choice at each of the 4 keys. – Mica – 2016-01-31T21:24:04.997

You can also change the font face by creating a string named FaceName with a value of Font Name at the 2 Console keys. Though if you want to use a font other than Lucida or Consolas, you'll first have to create a string named 000 with a value of your Font Name at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont – Mica – 2016-01-31T21:25:00.413

1This is arcane stuff. I am sure I have missed some details. Hope others can help me out! – Jay Bazuzi – 2012-12-22T15:01:25.870

1+1 Jay, I think Jay got it right, depends on how/where ps is run and the window opens up with the properties of that shortcut or exe – Logman – 2012-12-22T15:11:20.577

I have checked provided registry paths - they don't have any information about white/blue colors used by pinned powershell. Adding custom colors into them don't affect pinned powershell :(. So question is still active - where pinned powershell settings are stored and how they can be altered :). – grigoryvp – 2012-12-22T21:04:36.207

@EyeofHell: Did you look at the shortcut? I checked mine and confirmed that the white/blue color scheme is set there, not in the registry. I am editing my answer to make that more clear. – Jay Bazuzi – 2012-12-22T23:45:30.907

This is a great answer. For what it is worth, I personally set foreground and background colors in the powershell profile (Get-Help about_Profiles). That way I can have different colors for my regular account vs. my domain admin account so I hopefully don't try stupid things as a domain admin. – EBGreen – 2012-12-26T15:01:22.810