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:
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:
Also for PowerShell — Staffan Gustafsson converted MakeMeAdmin to a PowerShell script:
[2007-06-25: Update posted here.]