当您从其中一个预安装的快捷方式启动PowerShell窗口时,我会依赖它的漂亮蓝色.但是,如果你手动启动powershell.exe,你没有得到这些颜色,你得到黑/白:(
这是因为默认设置是在快捷方式(.lnk)文件上设置的:

我在Explorer上下文菜单中有一个"PowerShell Prompt Here"条目,我希望它使用与通常的快捷方式相同的漂亮颜色来启动PowerShell; 黑色很糟糕,而且有不同颜色的窗户会让人感到困惑(特别是当我有一些经常打开的老式指令窗户也是黑色的时候!).
到目前为止,我发现了两个问题:
有没有办法从命令行启动PowerShell(即我可以将其作为资源管理器上下文菜单项嵌入到注册表中),它将使用与快捷方式相同的设置?
我试图设置所有窗口的透明度.我有以下代码.
public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll")]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 0x80000;
public const int LWA_ALPHA = 0x2;
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, EventArgs e)
{
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in …Run Code Online (Sandbox Code Playgroud)