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

5 views
Skip to first unread message

Arlen Holder

unread,
Jul 7, 2018, 11:01:36 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:
****************************************************************************
0 new messages