"It takes a little bit of suffering to be beautiful" is what Italians say.@hdmi Thanks for all your efforts! But very complicated and long.
You only need to run it one time, as it only creates the new task in Task Scheduler. So, the whole idea is to just keep the task in there after that. The command to run this task is simple and short, and should work even if you're logged in with a standard user account instead of an account that belongs to the Administrators group. It's this:
schtasks /run /tn Reset-Audio
@garlin had it right the first time, the task should ideally be run as SYSTEM, as this makes it easier to avoid pitfalls like the Access is denied error that you were experiencing. Setting the requested privilege to Highest causes it to request the highest. It doesn't mean that the highest will actually be granted.
For this specific intent/purpose (i.e. running pnputil), choosing SYSTEM avoids the need to expose Credentials, and it simplifies the logic as a bonus. There exist a lot of situations where choosing SYSTEM could cause serious problems (and could even be a security risk), but this isn't one of them.
Granting Authenticated Users permission to trigger the task by modifying the task's security descriptor is what avoids the Access is denied error without having to do anything else.
This also is why the command to run the task is just
schtasks /run /tn Reset-Audio
.Just in case you still don't understand why Task Scheduler is the way to go, it's because otherwise you will be greeted with the annoying UAC prompt each time before your command resets the audio device. (Disabling UAC is most definitely NOT recommended excepting only maybe if you really, REALLY know what you're doing, so...)
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