How to stop and restart Audio Service using a batch file?
Solution 1
Create a new text file. Then, paste the following code into it.
@echo off
net stop audiosrv
pause
net start audiosrv
pause
Save the file as a bat file. Open the bat file as admin.
Solution 2
Here find a script for running a batch file as an admin
@echo off
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
net stop audiosrv
pause
net start audiosrv
pause
Solution 3
A more comprehensive batch file approach:
@echo off
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
net stop audiosrv
pause
net stop AudioEndpointBuilder
pause
net start AudioEndpointBuilder
pause
net start audiosrv
pause
Solution 4
The audio service is started by Windows using local system account and therefore it is not possible to stop this service without administrator privileges as command net
outputs.
The solution is clicking with right (secondary) mouse button on batch file and click with left (primary) mouse button in context menu on Run as Administrator as Magoo already suggested before.
For testing a batch file just created, it is always useful to open a command prompt window and run the batch file from within this window by entering name (with path if needed) and hitting RETURN. A shortcut for opening a command prompt window can be found in Accessories menu of Windows start menu, or the command cmd.exe
is executed which also opens a console window.
LazerWing
Updated on October 06, 2020Comments
-
LazerWing over 3 years
I made a batch file with the following line
net stop audiosrv & net start audiosrv
It just flashes and closes, not actually doing the command. I think I saw something about administrator privileges in the command window but it flashed too fast to tell. What is wrong?
-
Bhargav Rao about 8 yearsHi, do add a bit of explanation along with the code as it helps to understand your code. Code only answers are frowned upon.
-
serup about 4 yearsI have noticed that if you have fx. "Lenovo Hotkey Client Loader", then trying to stop windows audio will result in a pop-up dialog asking for confirmation to stop other services -- any chance you know how to force them to stop ?