Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Efficient Windows Admin command prompt of any color in any desired location

31 views
Skip to first unread message

Arlen Holder

unread,
Jul 7, 2018, 11:01:34 PM7/7/18
to
Maybe you can *improve* our combined tribal knowledge?

Please look at "DESIRED IMPROVEMENTS" in the header & footer below.

What would be nice is someone who knows Windows who can add those
desired improvements to our combined tribal knowledge archives!
- https://tinyurl.com/alt-msdos-batch
- https://tinyurl.com/alt-comp-freeware
- https://tinyurl.com/windowsxp-general

****************************************************************************
Efficient Windows Admin command prompt of any color in any desired location

Please improve so that all benefit from your efforts.

DESIRED IMPROVEMENTS:
A. Figure out how to get method C to open up a red window instead of black.
B. Figure out how to get method C to work even if a folder isn't selected.
****************************************************************************
============================================================================
Quick summary of the various methods open-command-as-admin methods below:
============================================================================
A. Keyboard method to open a blue admin command prompt:
Windows+X,A
Brings up a blue "Administrator" powershell command window:
<http://img4.imagetitan.com/img.php?image=16_admincmd3849.gif>
B. Start Menu method to open a red admin command prompt:
Rightclick on the Windows-icon > Command Prompt (Admin)
Brings up a blue "Administrator" powershell command window:
Note: Shift-rightclick also works the same with the latest Windows 10.
<http://img4.imagetitan.com/img.php?image=16_admincmd3.gif>
C: Context Menu method to open a blue admin command prompt:
{Shift}RightClick on a folder to open an Admin command here
<http://img4.imagetitan.com/img.php?image=16_cmda_4.gif>
D. Shortcut method to open a red admin command prompt:
Put a shortcut to open an admin command anywhere
<http://img4.imagetitan.com/img.php?image=16_cmda_2.gif>
E. Batch file method to open a red admin command prompt:
Start > Run > cmda {Enter}
<http://img4.imagetitan.com/img.php?image=16_admincmd2.gif>
F. Context menu method to open a command window here as admin:
<http://img4.imagetitan.com/img.php?image=18_cmdwindow01.jpg>
etc.
============================================================================
Here are details for methods to create a colorized open-as-admin command:
============================================================================
A. Keyboard method to open a blue admin command prompt:
Windows+X,A
Note: Win+X brings up the right-click menu for the Start button.
<http://img4.imagetitan.com/img.php?image=16_cmda_3.gif>
Then A selects Command Prompt (Admin) or Windows PowerShell (Admin)
depending on which version of Windows 10 you have.
(Note: Win+A is the Action Center.)
============================================================================
B. Start Menu method to open a red admin command prompt:
Rightclick on the Windows-icon > Command Prompt (Admin)
or Shift-Rightclick on the Windows-icon > Command Prompt (Admin)
Note: Non-classic users should be able to omit the "Shift".
<http://img4.imagetitan.com/img.php?image=16_admincmd3.gif>
============================================================================
C: Context menu method to open a black command window here as admin:
RightClick a folder and you'll get a Windows Powershell menu.
ShiftRightClick a folder adds the option to open a cmd window here.

Creating & installing an inf adds the "Open command window here (admin)"
option to both situations.
<http://img4.imagetitan.com/img.php?image=16_cmda_4.gif>

Note that WinAero Tweaker v0.7.0.3+ also adds the context menu item.
http://winaero.com/download.php?view.1796
<http://img4.imagetitan.com/img.php?image=16_winaero_tweaker.gif>

a. Create the inf file below & put it wherever you place "inf" files:
For example: c:\app\os\bin\inf\CmdHereAsAdmin.inf
b. Right click on that inf file and select Install.
c. Right click on any folder in Windows Explorer, and select:
"Open command window here (admin)"
<http://img4.imagetitan.com/img.php?image=18_cmdwindow01.jpg>

*** begin CmdHereAsAdmin.inf ***
[version]
signature="$CHICAGO$"

[CmdHereAsAdminInstall]
CopyFiles = CmdHereAsAdmin.Files.Inf
AddReg = CmdHereAsAdmin.AddReg

[DefaultInstall]
CopyFiles = CmdHereAsAdmin.Files.Inf
AddReg = CmdHereAsAdmin.AddReg

[DefaultUnInstall]
DelFiles = CmdHereAsAdmin.Files.Inf
DelReg = CmdHereAsAdmin.DelReg

[SourceDisksNames]
55="Open command window here (admin)","",1

[SourceDisksFiles]
CmdHereAsAdmin.INF=55

[DestinationDirs]
CmdHereAsAdmin.Files.Inf = 17

[CmdHereAsAdmin.Files.Inf]
CmdHereAsAdmin.INF

[CmdHereAsAdmin.AddReg]
HKLM,%UDHERE%,DisplayName,,"%CmdHereAsAdminName%"
HKLM,%UDHERE%,UninstallString,,"rundll32.exe syssetup.dll,SetupInfObjectInstallAction DefaultUninstall 132 %17%\CmdHereAsAdmin.inf"
HKCR,Directory\Shell\runas,,,"%CmdHereAsAdminAccel%"
HKCR,Directory\Shell\runas\command,,,"%11%\cmd.exe /k cd /d ""%1"""
HKCR,Drive\Shell\runas,,,"%CmdHereAsAdminAccel%"
HKCR,Drive\Shell\runas\command,,,"%11%\cmd.exe /k cd /d ""%1"""

[CmdHereAsAdmin.DelReg]
HKLM,%UDHERE%
HKCR,Directory\Shell\runas
HKCR,Drive\Shell\runas

[Strings]
CmdHereAsAdminName="Open command window here as admin (Uninstall only)"
CmdHereAsAdminAccel="Open command window here (admin)"
UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\CmdHereAsAdmin"
***** end CmdHereAsAdmin.inf *****

Optionally, add a "regular" command-line context-menu entry:
a. Create the following registry file named & placed wherever you like,
For example: C:\app\os\bin\reg\CmdHereAsUser.reg
b. Doubleclick on that registry file to add the new context-menu command:
{Right-click anywhere in File Explorer} > Open command window here
c. Right click anywhere in Windows File Explorer to see the new entry:
<http://img4.imagetitan.com/img.php?image=18_cmdwindow01.jpg>

*** begin CmdHereAsUser.reg***
Windows Registry Editor Version 5.00

; Created by: Shawn Brink
; Created on: December 10th 2016
; Tutorial: https://www.tenforums.com/tutorials/72024-open-command-window-here-add-windows-10-a.html

[HKEY_CLASSES_ROOT\Directory\shell\cmd2]
@="@shell32.dll,-8506"
"Extended"=-
"Icon"="imageres.dll,-5323"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\cmd2\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd2]
@="@shell32.dll,-8506"
"Extended"=-
"Icon"="imageres.dll,-5323"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd2\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\Drive\shell\cmd2]
@="@shell32.dll,-8506"
"Extended"=-
"Icon"="imageres.dll,-5323"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Drive\shell\cmd2\command]
@="cmd.exe /s /k pushd \"%V\""

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\cmd2]
@="@shell32.dll,-8506"
"Extended"=-
"Icon"="imageres.dll,-5323"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\cmd2\command]
@="cmd.exe /s /k pushd \"%V\""
======================================================================
D. Shortcut method to open a red admin command prompt:

Rightclick in any folder (e.g., the Desktop) > New > Shortcut
Type a location of "cmd" (or "cmd.exe") sans quotes
Click Next
Type an optional name (e.g., "cmd as admin in Users with red background")
Click Finish.
Rightclick the new Shortcut > Properties
Change the Shortcut Target from C:\Windows\System32\cmd.exe
To any of the following tested examples:
[Note The "/d" allows opening on other disc volumes.]
<http://img4.imagetitan.com/img.php?image=16_cmda_1.gif>

a. C:\Windows\System32\cmd.exe /K "cd /d C:\Users"
b. %ComSpec% /K "cd /d %HomePath%"
c. %ComSpec% /K "cd %WinDir%"
d. %ComSpec% /K "cd %HomeDrive%%HomePath%"
etc.
Press the Advanced button
Check [x]Run as Administrator [OK]
<http://img4.imagetitan.com/img.php?image=16_admincmd1.gif>

Optionally set the shortcut properties as desired, for example:
Properties > General > Screen Background > Red = 100 [Apply]
Properties > Shortcut > Change Icon > (choose an icon) [OK][Apply]
Properties > Font > Size = 28 [OK]
etc.
<http://img4.imagetitan.com/img.php?image=16_cmda_2.gif>

Optionally set:
Start in = %HOMEDRIVE%%HOMEPATH% (the Target can override this setting)
Shortcut key = not set

Optionally place that "cmda" shortcut into your normal Windows menus:
Rightclick on the shortcut > Pin to Start (this won't always be there)
Rightclick on the shortcut > Pin to taskbar (this isn't always there)
Rightclick on the shortcut > Send to > Add to cascade menu
Rightclick on the shortcut > Send to > Add to heterodox menu
Rightclick on the shortcut > Send to > Add to quicklaunch menu
Rightclick on the shortcut > Send to > Add to taskbar menu
Rightclick on the shortcut > Send to > Add to senddo menu
etc.
<http://img4.imagetitan.com/img.php?image=18_cmdwindow02.jpg>

Optionally create a "Start > Run > cmda" command to that shortcut:
a. Put the shortut wherever you store your custom links, e.g.,
"c:\app\os\bin\lnk\cmda.lnk"
b. Create a new App Paths entry named whatever you like,
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
For example, you can name the new "App Paths" key: "cmda.exe"
c. Set the Default to the path of your cmda.bat file, for example:
Default = "c:\app\os\bin\lnk\cmda.lnk"
Note the ".lnk" extension is optional if that's the only file of
that name in this directory, so this also works in that case:
Default = "c:\app\os\bin\lnk\cmda"

Note: To set up user "Send to" context menus, please see the
separate apnote on setting up an efficient Win10 menu system
or simply place the desired shortcut in the default menu location.

HINTS:
a. SendTo => %APPDATA%\Microsoft\Windows\SendTo
b. Heterodox(user)=> %AppData%\Microsoft\Windows\Start Menu\Programs
c. Heterodox(global)=> %ProgramData%\Microsoft\Windows\Start Menu\Programs
d. Orthodox binary: %localappdata%\TileDataLayer\Database\vedatamodel.edb
e. Quicklaunch => %appdata%\Microsoft\Internet Explorer\Quick Launch
f. Taskbar => %appdata%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
g. Cascade => %ProgramData%\Microsoft\Windows\Start Menu\menu
[Taskbar: Toolbars > New Toolbar > {point to your cascade "menu"}]
etc.

Note: Another method to open a command prompt as admin is to create a
"normal" command prompt shortcut & then just right click on that
normal "Command Prompt" shortcut to select "Run as Administrator".
============================================================================
E. Batch file method to open a red admin command prompt:

Start > Run > cmda {Enter}
<http://img4.imagetitan.com/img.php?image=16_admincmd2.gif>

Create this batch file & put wherever you place batch files, e.g.,
C:\app\os\bin\bat\cmda.bat

***** begin cmda.bat *****
@ECHO OFF

REM Open a new shell "Run As Administrator"
REM This is a copy of the script by foxidrive on alt.msdos.batch
SETLOCAL ENABLEEXTENSIONS
IF NOT "%~1"=="" goto :START
SET LogFile=%TEMP%\cmda.vbs"
Echo Set UAC = CreateObject("Shell.Application") >"%LogFile%"
Echo UAC.ShellExecute "%~f0", "%cd%", "", "runas", 1 >>"%LogFile%"
Start "" /MIN "%LogFile%"
goto :EOF
:START
Cmd /k "CD /D "%*" & Echo Administrator: & color 4F"
:EOF
***** end cmda.bat *****

Create a new "App Paths" key named whatever you like, e.g., "cmda.exe"
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Set the Default to the path of your cmda.bat file, for example:
Default = "C:\app\os\bin\bat\cmda.bat"
============================================================================
DESIRED IMPROVEMENTS:
A. Figure out how to get method C to open up a red window instead of black.
B. Figure out how to get method C to work even if a folder isn't selected.
============================================================================
Note: Left justify all batch files, inf files, and registry files.
============================================================================
============================================================================
****************************************************************************
End:
****************************************************************************

Kerr-Mudd,John

unread,
Jul 8, 2018, 3:14:54 AM7/8/18
to
On Sun, 08 Jul 2018 03:01:33 GMT, Arlen Holder <arlen...@nospam.net>
wrote:

> Maybe you can *improve* our combined tribal knowledge?
>
> Please look at "DESIRED IMPROVEMENTS" in the header & footer below.
>
> What would be nice is someone who knows Windows who can add those
> desired improvements to our combined tribal knowledge archives!


> - https://tinyurl.com/alt-msdos-batch
You have that
> - https://tinyurl.com/alt-comp-freeware
Not applicable - xpost dropped
> - https://tinyurl.com/windowsxp-general
Windows-X A doesn't work in XP
This is usenet, not a web forum!

Seems you want a windows 10 tweaking group; which is where you posted.
alt.comp.os.windows-10

> ***********************************************************************
> ***** Efficient Windows Admin command prompt of any color in any
> desired location
>

Your request boils down to changing the colo(u)r of a cmd prompt window
launched from a context menu item off a folder.


for best results stick "color 56" in the launched batch. colon dash right
bracket.

--
Bah, and indeed, Humbug.

Arlen Holder

unread,
Jul 8, 2018, 3:17:23 PM7/8/18
to
On 8 Jul 2018 07:14:53 GMT, Kerr-Mudd,John wrote:

> Your request boils down to changing the colo(u)r of a cmd prompt window
> launched from a context menu item off a folder.

Thanks for your kind help - which solved the color problem after a few
empirical false starts.

The good news is that this new solution that you just helped me arrive at
below is now archived in the following newsgroups, which will benefit
everyone in them, now and in the future.
http://tinyurl.com/alt-msdos-batch
http://tinyurl.com/alt-comp-os-windows-10
http://tinyurl.com/microsoft-public-windowsxp-gen (30-char limit)

> for best results stick "color 56" in the launched batch. colon dash right
> bracket.

Thanks for hazarding advice, as I know it's always risky to try to help a
noob as the risk is that the technical morass is too deep for either of us
to get out of (e.g., ask me how many times I've bricked a system testing
things out like disabling cortana or disabling Windows updates!). :)

I admit I don't understand the location you're referring to as "launched
batch. colon dash" but the *only* place I surmise we "can" add the color is
in these two lines of the previously posted INF file:
HKCR,Directory\Shell\runas\command,,,"%11%\cmd.exe /k cd /d ""%1"""
HKCR,Drive\Shell\runas\command,,,"%11%\cmd.exe /k cd /d ""%1"""

Testing on the command line the "color 56" syntax, I find this hint:
C:\> %comspec% /? | findstr color
/T:fg Sets the foreground/background colors (see COLOR /? for more info)

Where following through on the suggestion provides this background info:
C:\> color /?
Color attributes are specified by TWO hex digits -- the first
corresponds to the background; the second the foreground. Each digit
can be any of the following values:
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White

I think that means we want "47" for a red background with white fonts
(which a "color 47" command confirms in a default black command window).
C:\> color 47
C:\> color
(The first command changed the colors, the second reversed that.)

I admit I don't understand the syntax of the two INF commands above, but I
can sort of kind of maybe see where I'd put the "color" option as:
C:\> cmd.exe -T:47
But that doesn't work in a command window like "color 47" did in that same
window, so I'll just test it experimentally (which always gets me in
trouble).

This seems intuitive to test (although that concept of intuitive syntax has
bitten me greatly in the past):
HKCR,Directory\Shell\runas\command,,,"%11%\cmd.exe /T:47 /k cd /d ""%1"""
HKCR,Drive\Shell\runas\command,,,"%11%\cmd.exe /k cd /d /T:47 ""%1"""

I changed "CmdHereAsAdmin.inf" to "CmdHereAsAdminRed.inf" and right clicked
on it and selected "install" to test it out...

Well - that gave an error ... but the error was unrelated, which was:
Files Needed. The file "CmdHereAsAdmin.INF" on Open command window
here (admin) is needed. Type the path where the file is located, and
then click OK.

I decided to just change the name back to "CmdHereAsAdmin.INF" which was
easier than changing all the references inside the file itself.

Voila!

Now when I right click on a folder, I get the same context menu entry that
says:
"Open command window here (admin)"
but which now opens that command window as a red background with a white
font (the purpose being so that we can tell it's not a "normal" command
window but a "red" admin command window).

Thank you for hazarding helpful advice, where I much appreciate the hint to
use the "color 56" option, and where the result will help anyone who wishes
to add an "Open a red command window here as admin" context menu entry on
any Windows version, from Win95 upwards (I would assume).

What's left is modifying the INF so that it works on more than just
folders, but which also works inside a folder when no folder is selected,
which is how the normal "Open a black command window here as the user"
works.

For example, after loading both the "user cmd" REG file and after loading
the "admin cmd" INF file, neither the "user cmd" or "admin cmd" context
menu entry shows up when I right click in white space on "My PC".
<http://img4.imagetitan.com/img.php?image=18_showuphere01.jpg>

But when I right click on "C:", the "user cmd" entry shows up,
while the "admin cmd" entry remains dormant:
<http://img4.imagetitan.com/img.php?image=18_showuphere02.jpg>

Similarly, when I right click in white space inside any one folder,
the "user cmd" shows up but the "admin command" remains hidden:
<http://img4.imagetitan.com/img.php?image=18_showuphere03.jpg>

Yet, when I right click on a folder, both finally show up:
<http://img4.imagetitan.com/img.php?image=18_showuphere04.jpg>

And, neither shows up when I right click on a file:
<http://img4.imagetitan.com/img.php?image=18_showuphere05.jpg>

My next task, which help is always requested, is to figure out how to give
myself, and all the users here, the new ability to open the red admin
command prompt in the same places where we already open the black user
command prompt - since - to my knowledge - nobody on the planet has posted
this capability yet (AFAIK).

Arlen Holder

unread,
Jul 8, 2018, 8:37:50 PM7/8/18
to
On 8 Jul 2018 19:17:22 GMT, Arlen Holder wrote:

> I admit I don't understand the syntax of the two INF commands above, but I
> can sort of kind of maybe see where I'd put the "color" option as:
> C:\> cmd.exe -T:47
> But that doesn't work in a command window like "color 47" did in that same
> window, so I'll just test it experimentally (which always gets me in
> trouble).

I belatedly realized my first test on the command syntax was wrong in that
the syntax is not "cmd.exe -T:47" but "cmd.exe /T:47" so I'm correcting
this for the record.

This shows that the "cmd /T:47" & "cmd /T:56" syntax works fine
inside a command window.
<http://img4.imagetitan.com/img.php?image=18_cmdwindow03.jpg>

Now the goal is to figure out what magic enables the user command
window context menu to open no matter where the mouse is, but
we can't get the admin command window menu to show up unless
we select a folder:
<http://img4.imagetitan.com/img.php?image=18_cmdwindow04.jpg>

Kerr-Mudd,John

unread,
Jul 9, 2018, 2:39:31 AM7/9/18
to
On Mon, 09 Jul 2018 00:37:49 GMT, Arlen Holder <arlen...@nospam.net>
wrote:

> "cmd /T:56"

clearly (or maybe not!) this was a joke. It's a horrid colo(u)r scheme.


cmd.exe /T:02

green screen retro is the only one for me.

Arlen Holder

unread,
Jul 9, 2018, 3:55:11 AM7/9/18
to
On 9 Jul 2018 06:39:30 GMT, Kerr-Mudd,John wrote:

> clearly (or maybe not!) this was a joke. It's a horrid colo(u)r scheme.
>
>
> cmd.exe /T:02
>
> green screen retro is the only one for me.

Hi John Kerr-Mudd,
I don't get jokes ... I've never gotten them.
I'm all facts, and only facts. So I appreciate that explanation.

Here, by the way, are the three color schemes side by side...
<http://img4.imagetitan.com/img.php?image=18_cmdwindow05.jpg>

The actual color scheme didn't matter anyway as what was important was the
fact that an admin window should stand apart on sight, and that the color
turned out to be trivial once I realized that you were telling me that the
command itself could specify the color:
<https://www.tenforums.com/tutorials/94004-customize-command-prompt-colors-windows.html>

I've moved on to solving the other part of the problem, which is that the
user-level "Open command window here (user)" REG file causes the menu to
show up under more circumstances than does the "Open command window here
(admin)" INF result.
<https://www.tenforums.com/tutorials/72024-open-command-window-here-add-windows-10-a.html>

By studying the registry after running both the REG & INF, I'm starting to
see how to add the context menu under various right-click circumstances.

To be clear, I have never dissected such things before, but I'm beginning
to figure out a solution empirically, where, when I'm done, everyone will
have both commands working anywhere they click:
* Open command window here (users) => works on both white space & folders
* Open command window here (admin) => only works on folders at the moment

If you don't hear back from me, it means I haven't found the solution yet.
If you hear back from me, that means everyone will have a working solution
by me that they can just cut and paste and it will work for them.

J. P. Gilliver (John)

unread,
Jul 9, 2018, 11:43:47 AM7/9/18
to
In message <XnsA91A4DEBCC...@85.214.115.223>,
"Kerr-Mudd,John" <nots...@invalid.org> writes:
>On Mon, 09 Jul 2018 00:37:49 GMT, Arlen Holder <arlen...@nospam.net>
>wrote:
>
>> "cmd /T:56"
>
>clearly (or maybe not!) this was a joke. It's a horrid colo(u)r scheme.
>
Indeed!
>
>cmd.exe /T:02
>
>green screen retro is the only one for me.
>
>
Being a Hitchhiker's Guide fan, I tried 00 - but it has a trap for that
)-:.

(The two digits - hex - are background/foreground; "Color /?" will list
what's what. And you can type color rather than restarting cmd if you
want to play: "color f0" for those that remember the ZX80/81 [Sinclair,
Timex I think in USA].)
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf

in the kingdom of the bland, the one idea is king. - Rory Bremner (on
politics), RT 2015/1/31-2/6

bushy555

unread,
Jul 10, 2018, 7:30:27 AM7/10/18
to
> And you can type color rather than restarting cmd if you
>want to play: "color f0" for those that remember the ZX80/81 [Sinclair,
> Timex I think in USA].)

Check it out. I reckon that this could be my first post to a newsgroup since ~1998.
Anyhoo, Wow, that colour F0 brings back a lot of bad memories when I had 850 bytes of a basic listing in memory and the screen started to shrink on a good old zx81! Still have three or four ZX81's under the house which I should dig out one day.


The Video Technology "Timex TX8000" (Otherwise known as a Laser 210 or VZ200 elsewhere throughout the world) used this default colour on their 6847 video chips:
(Same as the MC10 and others that use the motorola 6847 video chip)

COLOR 2A


...or my preference has always been Borlands Turbo Pascal / Turbo C scheme:
COLOR 1A or COLOR 1F

/Bushy

Kerr-Mudd,John

unread,
Jul 10, 2018, 8:10:01 AM7/10/18
to
On Tue, 10 Jul 2018 11:30:26 GMT, bushy555 <dave.m...@gmail.com>
wrote:
3B looks OK
1E was the Amstrad CPC 464 non-PC "scheme"
0 new messages