Running a Root/Administrator Console from any Folder

WolfPack 0 Tallied Votes 355 Views Share

This blog entry is regarding a registry hack for Windows XP. Be advised that twiddling with the registry requires care, and use the information here at your own risk. the registry before proceeding is adviced.

This is a based on the tweak that is fairly common in the internet. What the original tweak basically did was, create a shortcut in the Directory/Drive Context Menu of Windows Explorer when clicked executes a command prompt with the clicked directory as current directory.

This modification was created so that I could run a root console from any directory or drive even when I was logged in as a restricted user. This can come in handy because then you can run many programs in restricted mode without re-login in as Administrator. Of course there is the Runas menu for executables, but you don't get it for Folders and directories.

What you have to do is simple. Copy and paste the following code in to notepad and save the resulting file in any name of ".reg" extension. E.g. RootConsole.reg
Then do a one time login as Administrator and double click the newly created .reg file. If all goes well, you should see a Shortcut called "Open Root Console Here" when you right click a Directory or Drive. When selected it will open a Command Promt , ask you for the administrator password, and open up a Admin Console for you in the selected directory if the password given is correct.

Note.
You will have to replace COMPUTER_NAME with your computer name, and AdministratorName with your administrator account name.
E.G. My Computer name was Laptop
My administrator name was Administrator
You should have the Registry Version in the heading of the reg file. I think it differs depending on the windows OS version. But version 5.00 should be okay for Windows XP and above. I think REGEDIT4 should work for Windows 2000. You can find it by running regedit.exe from Start Menu + Run, and clicking Help + About Registry Editor.

This is the complete .reg file.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_root]
@="Open Root Console Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\cmd_root\command]
@="runas /user:COMPUTER_NAME\\AdministratorName \"Cmd.exe /k pushd %L\""

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\cmd_root]
@="Open Root Console Here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\cmd_root\command]
@="runas /user:COMPUTER_NAME\\AdministratorName \"Cmd.exe /k pushd %L\""

Dani AI

Generated

Good find, — that registry approach is the classic XP-era way to add a “open a command prompt from this folder” entry and to launch a command shell under an administrative account without re‑logging. It’s important to note the platform difference: Windows XP behaved differently because it had no UAC; starting with Vista the elevation model changed and a simple runas-based registry verb no longer produces the same UAC-elevated token. (vdoc.pub)

Clarification of terms helps avoid surprises. The old CLI tool runas.exe launches a process under different credentials but does not reliably produce an elevated (UAC) token on Vista+; the shell’s runas verb / ShellExecute and PowerShell’s Start-Process -Verb RunAs are the mechanisms that invoke the UAC elevation prompt. For modern Windows, prefer calling an elevation verb (Start-Process -Verb RunAs) from the context-menu command so the process truly runs elevated. (devblogs.microsoft.com)

Practical tips and gotchas: use the shell variables correctly (%V/%L) and pushd so the console also switches drives; the difference between Directory, Directory\Background and Drive keys affects whether the entry appears when right‑clicking a folder icon or the whitespace inside a folder; Explorer must be refreshed/logged off for registry changes to show. For a modern, elevation-friendly command value the registry command can call PowerShell to start cmd elevated — for example:

powershell -WindowStyle Hidden -Command "Start-Process cmd -ArgumentList '/s','/k','pushd','%V' -Verb RunAs"

(the example shows the approach; quoting/escaping needs to be adapted for a .reg entry). (superuser.com)

Security notes: do not use runas /savecred on shared or production systems — it stores credentials and is a significant risk. For unattended elevated runs, a scheduled task configured to “run with highest privileges” is a safer automation pattern than saving admin passwords in Credential Manager. Also remember modern Windows often has the built‑in Administrator account disabled by default; using that account requires explicit enabling and a strong password. (tutorialreference.com)

Summary: the OP’s idea is valid for XP; on Vista+ adapt the command to invoke the elevation verb (PowerShell Start-Process -Verb RunAs), use %V/pushd for correct working folders, and avoid /savecred—test changes on a non‑production system and keep a registry backup.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.