guide · static export
Productivity

Run Commands as Admin with Sudo in Windows 11

The built-in sudo of Windows 11 24H2: three modes, one config command, and why your output ends up in the wrong window.

by@guidox updated:10/31/26 time:10 min level:Beginner tested on:Windows 11 24H2 works on:Windows 11 tools:Windows Terminal, Windows 11 24H2
TL;DR

Windows 11 24H2 ships a real **sudo**. Enable it with `sudo config --enable inline`, then prefix any console command to run it elevated in the same window.

Before you start

Requirements

  • Windows 11 24H2 or newer
  • Admin rights once
  • Ten minutes
Step by step

Instructions

01

Check the build number

Sudo arrived in build 26100. On anything older the command is unknown, and no amount of enabling will bring it back.

[System.Environment]::OSVersion.Version.Build
02

Enable it in settings

The switch lives in the developer section. Enabling it adds the console application to the system path for the current user.

Settings > System > For developers > Enable sudo
03

Choose the mode that fits your workflow

Inline keeps the output in the current window, forceNewWindow opens a second elevated console, normal asks in place. The config command with no argument prints the active mode.

sudo config --enable inline
tipInline is the mode that makes redirection and piping behave the way you expect, so start there.
04

Run a command that needs elevation

The prefix replaces the detour through a new administrator terminal. The UAC prompt still appears once per command, because sudo grants nothing on its own.

sudo netsh advfirewall show allprofiles state
05

Keep the output where you want it

With forceNewWindow the redirection happens in the new window, so the file you named stays empty. Inline writes into the current shell and the redirect lands in the folder you are in.

sudo ipconfig /flushdns > C:\Temp\dns.txt
⚠ warningCreate the target folder first. A redirect into a missing path fails after the command already ran.
06

Know where it stops

Sudo elevates console programs. A graphical app started this way can appear without an obvious prompt while still running in your user context, and interactive tools that own the console behave badly in inline mode.

tipFor a long session of many commands, one elevated terminal is still faster than prefixing every line.
Troubleshooting

Common issues

sudo is not recognized

The build is below 26100 or the feature is off. Enable it, then open a fresh terminal so the path is reloaded.

A UAC prompt appears every time

That is the design. Sudo does not cache elevation, unlike the Linux timestamp.

The command runs but prints nothing

forceNewWindow sends the output to the other console. Switch to inline.

A tool still says access denied

Some tools check the token of the parent process. Start that particular terminal elevated instead.

FAQ

Frequently asked

Is this the Linux sudo?

The same idea, a separate implementation: no sudoers file, no cached timestamp, and UAC remains the gate.

Does it work in PowerShell 7 and Windows Terminal?

Yes. The executable sits in System32 and works in any console host.

How to undo this

sudo config --disable turns the feature off again. No registry keys are left behind and existing terminals keep working with their current token.

Changelog · 1 entry
  1. 2026-10-31
    First version
Interactive version: checklist, feedback, related guides →

Free · no account needed · tracks your progress