简体   繁体   English

使用“运行Powershell”来调用脚本不会显示DarkMagenta背景

[英]Using “Run with Powershell” to invoke a script won't show a DarkMagenta background

I have the following script in a ps1 file: 我在ps1文件中有以下脚本:

Write-Host "Hello world" -ForegroundColor White -BackgroundColor DarkMagenta

If I open a Powershell window myself, and invoke the script (by just running .\\myscript.ps1 ), then I get a nice dark magenta background. 如果我自己打开一个Powershell窗口并调用脚本(仅通过运行。\\ myscript.ps1 ),那么我会得到一个很好的深洋红色背景。 However, if I right-click on the ps1 file and select "Run with Powershell", I don't get a dark magenta background. 但是,如果我右键单击ps1文件并选择“使用Powershell运行”,则不会得到深洋红色的背景。 Other background colors work fine though. 其他背景颜色也可以。

What is going on and how can I make them behave in the same way? 这是怎么回事,如何使它们表现相同?

The 16 console colors are determined by ColorTable00 .. ColorTable15 in the registry under HKCU:console or any other shortcut used to start an app. 16种控制台颜色由HKCU:控制台下注册表中的ColorTable00 .. ColorTable15或用于启动应用程序的任何其他快捷方式确定。

This slightly reworked table shows the normal entries and the two differing entries 05 and 06 for powershell. 稍作修改的表显示了常规条目以及powershell的两个不同条目05和06。

                                             Blue Green Red
> REG QUERY "hkcu\console" |find /I "ColorTable"
    ColorTable00    REG_DWORD    0x000000       0    0    0 
    ColorTable01    REG_DWORD    0x800000     128    0    0
    ColorTable02    REG_DWORD    0x008000       0  128    0
    ColorTable03    REG_DWORD    0x808000     128  128    0
    ColorTable04    REG_DWORD    0x000080       0    0  128
    ColorTable05    REG_DWORD    0x800080     128    0  128
    ColorTable06    REG_DWORD    0x008080       0  128  128
    ColorTable07    REG_DWORD    0xc0c0c0     192  192  192
    ColorTable08    REG_DWORD    0x808080     128  128  128
    ColorTable09    REG_DWORD    0xff0000     255    0    0
    ColorTable10    REG_DWORD    0x00ff00       0  255    0
    ColorTable11    REG_DWORD    0xffff00     255  255    0
    ColorTable12    REG_DWORD    0x0000ff       0    0  255
    ColorTable13    REG_DWORD    0xff00ff     255    0  255
    ColorTable14    REG_DWORD    0x00ffff       0  255  255
    ColorTable15    REG_DWORD    0xffffff     255  255  255
                                             Blue Green Red
HKCU\console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe
    ColorTable05    REG_DWORD    0x562401       1   86   36   
    ColorTable06    REG_DWORD    0xf0edee     238  237  240

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

相关问题 PowerShell脚本不会在ISE外部运行 - PowerShell script won't run outside of ISE cmd /C命令不会在后台执行powershell脚本 - cmd /C command won't execute powershell script in the background Hudson不会使用Powershell插件运行任何Powershell脚本 - Hudson won't run any Powershell scripts using Powershell plugin 使用Powershell脚本调用WebRequest - Invoke a WebRequest using Powershell Script 使用 PowerShell 调用服务器以运行 python 脚本:无法打开文件 [Errno 13] 权限被拒绝 - Invoke server with PowerShell to run python script: can't open file [Errno 13] Permission denied Powershell 脚本重命名文件添加最后修改日期到名称,脚本不会在子目录中运行 - Powershell script to rename Files adding Last Modified date to name, script won't run in sub directories 无法运行位于远程 Azure VM D 中的远程 powershell 脚本:使用 Invoke-Command 的驱动器 - Unable to run remote powershell script which is located in remote Azure VM D: drive using Invoke-Command 使用 Powershell 修改 Avaya CMS 脚本 (.acsauto),生成的脚本将无法运行 - Modifying an Avaya CMS script (.acsauto) with Powershell and the resulting script won't run Powershell 脚本不会使用给定的参数从 cmd.exe 运行文件 - Powershell script won't run file from cmd.exe with given parameters 为什么此Powershell脚本不接受参数? - Why won't this powershell script accept parameters?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM