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:

1
  • Just an FYI, most cmd programs are accessible in PowerShell the same way they are in cmd, and for the handful that aren't, execute via cmd /c <program> Commented Feb 4, 2025 at 16:43

1 Answer 1

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.