Created
November 20, 2014 19:49
-
-
Save zekesonxx/202a3e023b1510551463 to your computer and use it in GitHub Desktop.
Quick batch file fix for Windows randomly deciding to hate audio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Hello! | |
:: This is a batch file to fix Windows being a pile of shit with audio drivers. | |
:: There's not actually a real solution to this problem, but this is a quick fix. | |
:: | |
:: Solution found by: https://superuser.com/questions/20156 | |
:: All credit goes to Superuser user Jeff Atwood https://superuser.com/users/1 | |
:: BatchGotAdmin | |
:: Credit: https://stackoverflow.com/questions/1894967 | |
:------------------------------------- | |
@echo off | |
REM --> Check for permissions | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
REM --> If error flag set, we do not have admin. | |
if '%errorlevel%' NEQ '0' ( | |
echo Requesting administrative privileges... | |
goto UACPrompt | |
) else ( goto gotAdmin ) | |
: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 | |
:gotAdmin | |
pushd "%CD%" | |
CD /D "%~dp0" | |
:-------------------------------------- | |
@echo on | |
:: (this is the actual fix, the above is to get admin privileges) | |
net stop audiosrv | |
net start audiosrv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment