I\'m attached to the nice blue colour of the PowerShell window when you launch it from one of the pre-installed shortcuts. However, if you manually launch powershell.exe, yo
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.
.LNK
" extension to %PATHEXT%
environment variableThis allows system to execute files with .lnk
extension (hidden extension for shortcuts)
powershell
fileThis allows the powershell
command to launch our shortcut from system32
folder (which is in %PATH%
)
Use explorer (copy+rename) or the command-line below:
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" "C:\Windows\System32\powershell.lnk"
powershell_here.reg
file and execute it.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'"
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
Launch powershell with default blue and white colors in current folder from Explore or Total Commander or Double Commander on Windows 7 Pro 64-bit:
Create a batch file named ps.bat somewhere in a folder that is on the system PATH (if you do not have such a folder just make one, let's say C:\run\cli and add it to the PATH system environment variable). This batch file has to contain the following command:
start "" "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk"
That's it. Now just type ps in the Explorer's path bar where the current folder is shown or in the command line box of Total Commander or Double Commander, etc...
On Windows 10, there is no need to modify the PowerShell shortcut from Start Menu and the ps.bat file from above may contain just the following command:
start %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Here's a really easy way:
Start -> run "sysdm.cpl" -> advanced -> Environment Variables
Scroll Down through system variables, double click PATHEXT
Add .LNK; as depicted below:
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" "C:\Windows\System32\powershell.lnk"
You can further customize the .lnk in C:\Windows\System32 to your liking.
Please note that this will only work because you have added the .lnk to the list of acceptable extensions AND c:\windows\system32 is the first item in the search path (PATH system variable) by default.
This will not customize the console if it is launched via cmd.exe.
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
Edit your profile script (pointed to by $profile) and set the desired colors yourself:
# 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
regedit
command to open registry editorHKEY_CURRENT_USER > CONSOLE
and Backup entire folder by exporting just in caseRestart 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