Skip to content

Instantly share code, notes, and snippets.

@tigerhawkvok
Created March 4, 2016 20:30
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tigerhawkvok/b27b0cbaca2deda1ae33 to your computer and use it in GitHub Desktop.
Save tigerhawkvok/b27b0cbaca2deda1ae33 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