1

In Windows Explorer, I often do CTRL+L c m d ENTER to quickly launch a cmd.exe shell with the working directory being the current Explorer folder. It's a handy and quick 1-second shortcut. (I don't use Powershell, I prefer cmd.exe)

But then, the cmd.exe which is started is not admin, even though my current Windows user is Administrator.

Example: mklink .... gives You do not have sufficient privilege to perform this operation (see also: Why can't I make a symbolic link (mklink) even when I'm an administrator)

How to launch an (administrator) cmd.exe from a Windows Explorer window, with the current working directory = the current folder in Explorer?

Notes:

Basj
  • 2,143

2 Answers2

3

Put this as a.vbs into one of the front entries of %PATH% and do CTRL+L a . v b s ENTER wherever you are.

Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
currentDir = wshShell.CurrentDirectory
objShell.ShellExecute "cmd.exe", "/K chdir /D " & currentDir, "", "runas", 1

This is faster than powershell and independent of execution policies. By using .vbs no intermediate window is shown. Confirm the opening UAC by ENTER

cachius
  • 859
1
Open the Windows Terminal, and enter its settings
In settings under 'Default profile', set default behavior to start CMD
Screenshot of a Windows Terminal settings window, Startup section
  • Now from folder where you are in, as you did before with the keycombo

          1. Press Shift+F10,
          2. Tap up arrow twice to select "Terminal" (letter T acts up on Win11)
          3. Press Shift+Ctrl+Enter, starts in directory as whoever you enter in UAC.

Shift+Ctrl+T while in Terminal opens a new tab (Ctrl+T does the same for explorer.exe, if that's useful).

Danijel
  • 461