Skip to content

Instantly share code, notes, and snippets.

@twerp
Forked from tigerhawkvok/restartAudio.bat
Created January 12, 2019 17:54
Show Gist options
  • Save twerp/856663dfedf5e295a8b4a16ccbac2ef5 to your computer and use it in GitHub Desktop.
Save twerp/856663dfedf5e295a8b4a16ccbac2ef5 to your computer and use it in GitHub Desktop.
Restart Windows Audio Service (with admin permissions, if needed)
rem Written for buggy audio drivers that need to be restarted
rem In my case, the Claro 8.18 drivers bug out every once in a while on Windows 10, and need restarting to not sound poppy
@echo off
goto check_Permissions
:check_Permissions
echo Administrative permissions required to run this script. Checking...
net session >nul 2>&1
if %errorLevel% == 0 (
goto gotAdmin
) else (
goto UACPrompt
)
pause >nul
exit
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
net stop audiosrv /y
net stop AudioEndpointBuilder /y
net start audiosrv
net start AudioEndpointBuilder
rem This next line is just for my configuration, or anyone else that has Razer headphones
net start RzSurroundVADStreamingService
exit
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment