How to combine runas with pnputil?


johnaw

New member
Local time
7:27 PM
Posts
10
OS
Windows 11
i want to use runas to disable audio. Once i get this working i'll put it into a .bat file.
Reason: The laptop often or always doesn't recognize my 1/8th" headphone plug when i insert it. Disabling/Reenabling this driver forces the system to recognize the headphones

I'm on Win 11, but these commands go back decades.

This works from admin command line.
Code:
pnputil /disable-device "INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001"

You can see the driver get disabled in Device Manager. The path is "device instance path" in driver properties.

audio-driver.webp device-instance.webp

Now i'm trying to make it work with runas, but no joy. These don't work:
Code:
runas /savecred /user:BOOMBOX\BOOM pnputil /disable-device "INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001"
Code:
runas /user:BOOMBOX\BOOM "start \"\" pnputil /disable-device \"INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001\""
Code:
runas /user:BOOMBOX\BOOM "start """" pnputil /disable-device ""INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001"""
Code:
runas /user:BOOMBOX\BOOM "cmd pnputil /disable-device \"INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001\""

I don't care to use cmd or start, but i think it might be necessary. Would be great if they weren't necessary (use runas alone).

I looked here, but still stuck.

Any ideas?
Thx!

Also asked on tenforums and windowscentral.com.
 
Last edited:

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
My preference is to use Elevated scheduled tasks, and not bother with RUNAS credentials.

1. Create a pair of elevated tasks as the Administrator:
Code:
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /f

schtasks /create /sc ONCE /tn Enable-Audio /tr "pnputil /enable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /f

2. As an ordinary user, run tasks from the command-line or a batch file:
Code:
schtasks /run /tn Enable-Audio
MyAudio_App.exe
schtasks /run /tn Disable-Audio
 

My Computer

System One

  • OS
    Windows 7
My preference is to use Elevated scheduled tasks, and not bother with RUNAS credentials.

1. Create a pair of elevated tasks as the Administrator:
Code:
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /f

schtasks /create /sc ONCE /tn Enable-Audio /tr "pnputil /enable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /f

2. As an ordinary user, run tasks from the command-line or a batch file:
Code:
schtasks /run /tn Enable-Audio
MyAudio_App.exe
schtasks /run /tn Disable-Audio
this or ahk is the route i'd go as well. if op wants other options, you can use nirsoft tools as well...

 

My Computer

System One

  • OS
    Windows 11 Pro
use Elevated scheduled task

1. Create as the Administrator:
Code:
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /f

2. As an ordinary user, run tasks from the command-line or a batch file:
Code:
schtasks /run /tn Disable-Audio
MyAudio_App.exe

Awesome solution. I assume MyAudio_App.exe is simply the software I'm using which outputs audio to the headphones. For example a web browser. In my case it's the browser and any other software that outputs audio. I don't need to launch the browser from this script, and I suggest it is confusing to include it in your solution because it's not really part of the solution.

I'm not enabling audio just to run an app one time. I need to fix an issue which prevents the headphones from being detected properly when plugged in. The fix is to disable the driver and then re-enable the driver, and not to enable the driver and then disable the driver as you have shown.

this or ahk is the route i'd go as well. if op wants other options, you can use nirsoft tools as well...

Thanks for that! I prefer using native Windows features whenever possible.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Code:
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /f

Do your schtasks commands work for you? I'm getting:
ERROR: No value specified for /ST option.

Help says:
Code:
/ST   starttime    Specifies the start time to run the task. The time
                       format is HH:mm (24 hour time) for example, 14:30 for
                       2:30 PM. Defaults to current time if /ST is not
                       specified.  This option is required with /SC ONCE.

/SC   schedule     Specifies the schedule frequency.
                       Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY,
                       MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT.

I don't want this to run according to any schedule, just when i manually fire it. Should i choose ONEVENT? It's unclear what the "event" should be. Are you sure this is the correct solution for manual execution?

Thx
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Sorry, forgot to provide a dummy /ST value.
Code:
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /st 00:00 /f
 

My Computer

System One

  • OS
    Windows 7
Sorry, forgot to provide a dummy /ST value.
Code:
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /ru SYSTEM /rl HIGHEST /st 00:00 /f
Does this work for you at non-admin cmd? I get "access denied" at non-admin cmd. So i still need to use runas in the .bat file, correct?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
You have to run the "schtasks create" command once as Administrator.
Afterwards any user can call "schtasks /run /tn TaskName" without needing any special permissions.
 

My Computer

System One

  • OS
    Windows 7
You have to run the "schtasks create" command once as Administrator.
Afterwards any user can call "schtasks /run /tn TaskName" without needing any special permissions.
Works for you? That's what i did. Ran once at admin cmd. See creation error re /ST:

1752731623757.webp

Now getting "access denied" at non-admin console:

1752731719798.webp

Also, this fails. I get prompt for password, but the device doesn't get disabled.
Code:
>runas /user:BOOMBOX\BOOM "schtasks /run /tn Disable-Audio"
Enter the password for BOOMBOX\BOOM:
Attempting to start schtasks /run /tn Disable-Audio as user "BOOMBOX\BOOM" ...
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Here is my preferred method for doing this from a batch file:

Create a self-elevating batch file so that if it is not run as admin it will terminate itself and re-launch itself elevated.

Here is an example:

NOTE: The device I was testing with is a different one than you were using. Make sure to change this:

Batch:
@echo off

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Check to see if this batch file is being run as Administrator. If it is not, then rerun the batch file ::
:: automatically as admin and terminate the intial instance of the batch file.                            ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

(Fsutil Dirty Query %SystemDrive%>Nul)||(PowerShell start """%~f0""" -verb RunAs & Exit /B)

::::::::::::::::::::::::::::::::::::::::::::::::
:: End Routine to check if being run as Admin ::
::::::::::::::::::::::::::::::::::::::::::::::::

:: We reach this point once the batch file is run as admin

pnputil /disable-device "HDAUDIO\SUBFUNC_01&VEN_8086&DEV_2812&NID_0001&SUBSYS_00000000&REV_1000\5&20D072F3&0&0002&00000014"
 

My Computers

System One System Two

  • OS
    Win11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self-built
    CPU
    Intel i7 11700K
    Motherboard
    ASUS Prime Z590-A MB
    Memory
    64GB (Waiting for warranty replacement of another 64GB for 128GB total)
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    HP Envy 32
    Screen Resolution
    2560 x 1440
    Hard Drives
    1 x 1TB NVMe SSD
    1 x 2TB NVMe SSD
    1 x 4TB NVMe SSD
    3 x 512GB 2.5" SSD
    1 x 4TB 2.5" SSD
    5 x 8TB Seagate Barracuda HDD
    PSU
    Corsair HX850i
    Case
    Corsair iCUE RGB 5000X mid tower case
    Cooling
    Noctua NF-S12A chromax.black.swap case fans (Qty. 7) & Home Computer Specifications, Configuration, and Usage Notes General Specifications ASUS Prime Z590-A motherboard, serial number M1M0KC222467ARP Intel Core i7-11700K CPU (11th Gen Rocket Lake / LGA 1200 Socket) 128GB Crucial Ballistix RGB DDR4 3200 MHz DRAM (4 x 32GB) Corsair iCUE RGB 5000X mid tower case Noctua NH-D15 chromax.black CPU cooler Noctua NF-S12A chromax.black.swap case fans (Qty. 7) & Corsair LL-120 RGB Fans (Qty. 3)
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    The five 8TB drives and three 512GB SSDs are part of a DrivePool using StableBit DrivePool software. The three SSDs are devoted purely to caching for the 8TB drives. All of the important data is stored in triplicate so that I can withstand simultaneous failure of 2 disks.

    Networking: 2.5Gbps Ethernet and WiFi 6e
  • Operating System
    Win11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
Create a self-elevating batch file so that if it is not run as admin it will terminate itself and re-launch itself elevated.
Neat! But seems a bit indirect/janky. It's on my list to try, if other cleaner approaches can't be solved. Thx!
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Neat! But seems a bit indirect/janky. It's on my list to try, if other cleaner approaches can't be solved. Thx!

Of course everyone has their own preferred methods, but I literally use this in dozens of batch files, including some of a few thousand lines in length and everything works flawlessly - not at all janky.

The only way I have not tested is to see what happens if I am logged in as a non-admin user. Should still work although I suspect that it may prompt for user creds then. I have never been interested in testing this only because I have no standard user accounts anywhere :-)
 

My Computers

System One System Two

  • OS
    Win11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Self-built
    CPU
    Intel i7 11700K
    Motherboard
    ASUS Prime Z590-A MB
    Memory
    64GB (Waiting for warranty replacement of another 64GB for 128GB total)
    Graphics Card(s)
    No GPU - Built-in Intel Graphics
    Sound Card
    Integrated
    Monitor(s) Displays
    HP Envy 32
    Screen Resolution
    2560 x 1440
    Hard Drives
    1 x 1TB NVMe SSD
    1 x 2TB NVMe SSD
    1 x 4TB NVMe SSD
    3 x 512GB 2.5" SSD
    1 x 4TB 2.5" SSD
    5 x 8TB Seagate Barracuda HDD
    PSU
    Corsair HX850i
    Case
    Corsair iCUE RGB 5000X mid tower case
    Cooling
    Noctua NF-S12A chromax.black.swap case fans (Qty. 7) & Home Computer Specifications, Configuration, and Usage Notes General Specifications ASUS Prime Z590-A motherboard, serial number M1M0KC222467ARP Intel Core i7-11700K CPU (11th Gen Rocket Lake / LGA 1200 Socket) 128GB Crucial Ballistix RGB DDR4 3200 MHz DRAM (4 x 32GB) Corsair iCUE RGB 5000X mid tower case Noctua NH-D15 chromax.black CPU cooler Noctua NF-S12A chromax.black.swap case fans (Qty. 7) & Corsair LL-120 RGB Fans (Qty. 3)
    Keyboard
    Corsair K70 Max RGB Magnetic Keyboard
    Mouse
    Logitech MX Master 3
    Internet Speed
    1Gb Up / 1 Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    The five 8TB drives and three 512GB SSDs are part of a DrivePool using StableBit DrivePool software. The three SSDs are devoted purely to caching for the 8TB drives. All of the important data is stored in triplicate so that I can withstand simultaneous failure of 2 disks.

    Networking: 2.5Gbps Ethernet and WiFi 6e
  • Operating System
    Win11 Pro 23H2
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo ThinkBook 13x Gen 2
    CPU
    Intel i7-1255U
    Memory
    16 GB
    Graphics card(s)
    Intel Iris Xe Graphics
    Sound Card
    Realtek® ALC3306-CG codec
    Monitor(s) Displays
    13.3-inch IPS Display
    Screen Resolution
    WQXGA (2560 x 1600)
    Hard Drives
    2 TB 4 x 4 NVMe SSD
    PSU
    USB-C / Thunderbolt 4 Power / Charging
    Keyboard
    Backlit, spill resistant keyboard
    Mouse
    Buttonless Glass Precision Touchpad
    Internet Speed
    1Gb Up / 1Gb Down
    Browser
    Edge
    Antivirus
    Windows Defender
    Other Info
    WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor
Of course everyone has their own preferred methods, but I literally use this in dozens of batch files, including some of a few thousand lines in length and everything works flawlessly - not at all janky.

The only way I have not tested is to see what happens if I am logged in as a non-admin user. Should still work although I suspect that it may prompt for user creds then. I have never been interested in testing this only because I have no standard user accounts anywhere :-)

By "janky", i didn't mean unreliable. Maybe "hacky" is a better word?
For security, i never use Win admin accounts for daily usage.
Cheers!
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Try this:
Code:
schtasks /delete /tn Disable-Audio
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /rl HIGHEST /st 00:00 /f

Running as SYSTEM was unnecessary for pnputil.

1752735729722.webp
 

My Computer

System One

  • OS
    Windows 7
Try this:
Code:
schtasks /delete /tn Disable-Audio
schtasks /create /sc ONCE /tn Disable-Audio /tr "pnputil /disable-device INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001" /rl HIGHEST /st 00:00 /f

Running as SYSTEM was unnecessary for pnputil.

Thx, but still getting access denied trying to run. Are you logged into Windows as non-admin?

1752736299796.webp
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Is your "Naj" user account the primary user on this PC? I had to delete and recreate the tasks a few times to get it run for me (not as Admin).
 

My Computer

System One

  • OS
    Windows 7
Is your "Naj" user account the primary user on this PC? I had to delete and recreate the tasks a few times to get it run for me (not as Admin).
What does 'primary user' mean? There are two accounts:
BOOM (admin, not logged in)
Naj (non-admin, logged in)
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude
Remove the task again (by running schtasks /delete /tn Disable-Audio as an administrator).
Next, try my batch script to create the task such a way that should fix the Access is denied problem:
Batch:
<# ::
@echo off
"%windir%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command ^$fp = '%~dpnx0'; Invoke-Expression ((Get-Content '%~dpnx0') -join [Environment]::NewLine); Elevate
goto :eof
#>
$Command = "`$fp = '$($fp)'; Write-Host 'Processing: ' -ForegroundColor Yellow -NoNewline; Write-Host `$fp; Invoke-Expression ((Get-Content `$fp) -join [Environment]::NewLine); if (`$fp -ne '') { Main }"
function Elevate {
  if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
    Start-Process "$env:windir\System32\WindowsPowerShell\v1.0\powershell.exe" "-NoProfile -ExecutionPolicy Bypass -Command `"$Command`""
  } else {
    Start-Process "$env:windir\System32\WindowsPowerShell\v1.0\powershell.exe" "-NoProfile -ExecutionPolicy Bypass -Command `"$Command`"" -Verb RunAs
  }
}
function Main {
$fp
  if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
    $taskName = 'Reset-Audio'
    $deviceId = '"INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001"'

    # Disable + Re-enable device
    $disableAction = New-ScheduledTaskAction -Execute "pnputil.exe" -Argument "/disable-device $deviceId"
    $enableAction  = New-ScheduledTaskAction -Execute "pnputil.exe" -Argument "/enable-device $deviceId"
    $actions = @($disableAction, $enableAction)

    # Harmless trigger to make the task valid
    $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date)

    # SYSTEM principal with full privileges
    $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest

    # Allow the task to run if on battery power
    $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable

    Register-ScheduledTask -TaskName $taskName -Action $actions -Trigger $trigger -Principal $principal -Settings $settings -Force

    # Grant run permission to Authenticated Users
    $scheduler = New-Object -ComObject "Schedule.Service"
    $scheduler.Connect()
    $task = $scheduler.GetFolder("\").GetTask($taskName)
    $sd = $task.GetSecurityDescriptor(0xF)
    if ($sd -notmatch 'A;;GRGX;;;AU') {
      $sd += '(A;;GRGX;;;AU)'
      $task.SetSecurityDescriptor($sd, 0)
    }
  } else { Write-Host "Couldn't elevate the script." -ForegroundColor Yellow }
  pause
}

EDIT: Corrected the quoted string for $deviceId.

EDIT2: Added settings to allow the task to run even if on battery power. Removed the addition of one minute from the trigger's start time (the -At parameter), as it isn't necessary.
 
Last edited:

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
@hdmi Thanks for all your efforts! But very complicated and long.

I got this one-liner working. So although i have to enter password, it's still preferable for its simplicity.
reset-audio.bat
Code:
powershell.exe -ExecutionPolicy Bypass Start-Process "pnputil" -ArgumentList '/disable-device "INTELAUDIO\FUNC_01&VEN_10EC&DEV_0295&SUBSYS_1028099F&REV_1000\5&1B578A47&0&0001"' -Verb RunAs

I'm optimistic that i may be able to embed credentials using this or something similar:
Code:
$password = ConvertTo-SecureString “PlainTextPassword” -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential (“username”, $password)
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude

Latest Support Threads

Back
Top Bottom