Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows 11 / Run Elevated Commands with Sudo on Windows 11

August 21, 2025

Run Elevated Commands with Sudo on Windows 11

Starting with build 24H2, Windows 11 includes a built-in sudo command. This command allows running commands as an administrator directly from an unprivileged (non-admin) CMD/PowerShell/Terminal session.

By default, the sudo command is disabled in Windows 11. To allow using this tool, use the Enable sudo toggle switch in Settings -> System -> For developers.

Enable sudo on Windows 11

Or you can enable sudo via the Windows registry.

reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Sudo" /v "Enabled" /t REG_DWORD /d 1 /f

For example, running the following PowerShell command to restart a Windows service from a non-elevated terminal will result in an error

Restart-Service iphlpsvc

Then, enable sudo in the Windows settings and run the same command via sudo.

sudo powershell "Restart-Service iphlpsvc"

A User Account Control (UAC) prompt will appear requesting privilege elevation. Once approved, a new terminal window is launched (separate from the current session where context was already established), and the specified command is executed with administrative rights.

sudo - UAC elevation prompt

Running elevated PowerShell command using sudo in Windows 11

Unlike runas, the sudo command doesn’t prompt for an administrator password in the command line. The UAC prompt is used to confirm and elevate the current user’s privileges, but it does not allow selecting a different user account for elevation.

In the same way, you can use Sudo in the CMD prompt. I’m trying to stop the service using a non-admin (non-elevated) command prompt.

net stop iphlpsvc

System error 5 has occurred.
Access is denied.

Now I run the same command via sudo:

sudo net stop iphlpsvc

use sudo command in CMD prompt

Previously, running a program or command with elevated permissions from a non-privileged console required launching a new Command Prompt window using the “Run as administrator” option. If the PowerShell console was running in non-admin mode, you had to start an elevated session from within the current session using this command:

Start-Process powershell -Verb runAs

Sudo for Windows runs apps with elevated privileges in three modes. These modes can be selected from the Settings app or specified from the command line.

  • In a new window – when a command or program is run via sudo, it opens in a new elevated window (session), running as an administrator. This is the default behavior. sudo config --enable forceNewWindow
  • With input disabled – this is the safest option, where the command runs with elevated privileges in the current window but cannot receive or prompt for user input within that session: sudo config --enable disableInput
  • Inline – this mode is most similar to the behavior of the sudo command in Linux and other OSs. An elevated command runs in the current console and can receive input from it (the most convenient but least secure option): sudo config --enable normal

sudo modes in Windows 11

You can run an elevated command in the current console using sudo, regardless of the current sudo mode. Just add the inline option.

sudo --inline net stop iphlpsvc

sudo --inline - elevate command in current session

To see the full list of supported sudo options and parameters in Windows, run the following command:

sudo -h

sudo command line options in Windows

2 comments
2
Facebook Twitter Google + Pinterest
PowerShellWindows 11
previous post
Find a Process Causing High Disk Usage on Windows
next post
PowerShell: The Module Could Not Be Loaded

Related Reading

Configuring RemoteApps Hosted on Windows 10/11 (without Windows...

January 25, 2025

Disable BitLocker Automatic Drive Encryption in Windows 11

October 16, 2024

Enable Hyper-V on Windows 10/11 Pro and Home...

August 12, 2024

Get Started with Docker on Windows (WSL2) without...

September 4, 2024

Disable and Completely Remove Widgets from Taskbar in...

September 26, 2024

Fix: Windows Update Tab (Button) is Missing from...

December 16, 2024

Change Network Connection (Adapter) Priorities in Windows

August 5, 2024

Check the Software Installation/Removal History in Windows

October 8, 2024

2 comments

Francesco August 22, 2025 - 8:15 am

Why the Restart-Service example above is “sudo run powershell restart-service iphlpsvc” and not “sudo restart-service iphlpsvc”?

Reply
admin September 2, 2025 - 8:35 am

These commands are equivalent. This is just for illustration purposes.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Windows Stucks at ‘Getting Windows Ready, Don’t Turn Off Computer ‘

    September 15, 2025
  • Clean Up ETL Log Files in ProgramData

    September 9, 2025
  • Fix: Slow Startup of PowerShell Console and Scripts

    September 3, 2025
  • DPI Scaling and Font Size in RDP (RDS) Session

    August 27, 2025
  • Proxmox: Share a Host Directory with VMs via VirtioFS

    August 18, 2025
  • How to Find AD Users with Blank Passwords (Password-Not-Required)

    July 24, 2025
  • Run Elevated Commands with Sudo on Windows 11

    July 16, 2025
  • Find a Process Causing High Disk Usage on Windows

    July 15, 2025
  • Fix: Microsoft Defender Not Updating Automatically in Windows

    July 8, 2025
  • Create a Windows Server VM on Proxmox (Step-by-Step)

    July 7, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Assign (Passthrough) a Physical GPU to a Hyper-V Virtual Machine
  • Run PowerShell Scripts on a Schedule with Task Scheduler
  • Extend an Expired User Password in Active Directory
  • Check Windows 11 Hardware Readiness with PowerShell Script
  • Check the Software Installation/Removal History in Windows
  • How to Add or Remove Pinned Folders to Quick Access with PowerShell and GPO
  • How to Enable and Configure Wake-on-LAN (WoL) in Windows
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top