Setting color for *all* CMD shells based on admin/elevation status

In my RunAs... and MakeMeAdmin posts, I recommend making your admin command shells visually different to set them apart from non-admin ones.  You can change the default console window color on a per-account basis, but that doesn't help when the same account may be used in both admin and non-admin contexts (such as with Vista's UAC admin-approval mode).  You can use the cmd.exe /T command-line option, or its built-in COLOR command, but it works only if you remember to use it each and every time.

Here's a way to make the differentiation happen with a one-time, one-line configuration change on your system, that will work on all CMD.EXE shells you run.  The idea is to run a non-destructive command that requires admin privileges from a CMD autorun location, test for success and set the console's color accordingly.  You can also change the title at the same time.

This can probably use some refinement.  For the non-destructive admin operation on Windows XP/2003, I suggest "bootcfg /query"; on Windows Vista, I suggest "bcdedit /enum".  The autorun location I've been playing with is:

    [HKLM\Software\Microsoft\Command Processor]
"AutoRun" (REG_SZ)

The command syntax you can set the "AutoRun" value to for Windows XP/2003 is:

    bootcfg /query >nul 2>nul && (color FC && title ADMIN) || (color 07 && title NONADMIN)

and for Windows Vista, set it to:

    bcdedit /enum >nul 2>nul && (color FC && title ADMIN) || (color 07 && title NONADMIN)

Any output or error message is redirected to "nul" so you don't see it.  If the command succeeds ( && ), you're running with admin/elevated privileges; the console color will change to bright-red-on-white (FC) and the title changed to "ADMIN".  If the command fails ( || ), the console color will be white-on-black (07) and the title changed to "NONADMIN".  Feel free to change the colors or titles to suit your taste.

All that stuff works only for CMD.EXE.  For Windows PowerShell, take a look at these:

https://www.interact-sw.co.uk/iangblog/2007/02/09/pshdetectelevation
https://www.leastprivilege.com/AdminTitleBarForPowerShell.aspx

Also for PowerShell -- Staffan Gustafsson converted MakeMeAdmin to a PowerShell script:

https://groups.archivesat.com/Windows_PowerShell/thread246430.htm

[2007-06-25: Update posted here .]