Advertisement
Chaos5715

Windows Default Audio Device Selector

Feb 20th, 2020
1,335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :: !!!Need to run as admin to enable taskkill command!!! (Can set to run as admin in properties if you create a shortcut of the batch file).
  2.  
  3. :: LINKS --
  4.  
  5. :: REQUIRED -- nircmd link - http://www.nirsoft.net/utils/nircmd.html
  6. :: REQUIRED -- Create a folder anywhere you like and extract nircmd (eg. C:\Program Files\audio device\).
  7. :: REQUIRED -- "nircmd" adds audio device control options, such as volume level and device switching.
  8.  
  9. :: Highly recommend "notepad++" text editor if you don't already have it. -- https://notepad-plus-plus.org/downloads/
  10. :: Optional, converts batch files into a program. -- bat to exe converter - http://www.softpedia.com/get/System/File-Management/Batch-To-Exe-Converter.shtml       
  11. :: Optional, allows you to create custom icons for your program. -- icon converter - http://icoconvert.com/
  12. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  13.  
  14. @ECHO off
  15. cls
  16. :: Size and color of window.
  17. title AUDIO
  18. mode con: cols=37 lines=12
  19. color 06
  20.  
  21. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  22. :: Prevents multiple instances, but not required. Remove both semicolons from desired section, or add to both sections to disable feature.
  23. :: Lines starting with 2 semicolons "::" are ignored.
  24. ::
  25.  
  26. :: If converted to exe. --  Replace "Audio.exe" with whatever you name the exe you create. Then remove semicolons from the next 2 lines, and add them to the section below.
  27. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  28. ::for /f %%A in ('tasklist ^| findstr /i "Audio.exe"') do set /a cnt+=1
  29. ::IF "%cnt%"=="1" goto start
  30. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  31.  
  32. :: If running as a batch file -- remove semicolons from the next 2 lines, and add them to the section above.
  33. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  34. ::for /f %%A in ('tasklist ^| findstr /i "cmd.exe"') do set /a cnt+=1
  35. ::IF "%cnt%"=="2" goto start
  36. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  37. ::goto end
  38.  
  39. :start
  40. ECHO -----------------------------------
  41. ECHO.
  42. ECHO. AUDIO DEVICES
  43. ECHO.
  44. :: Anything after "ECHO" is displayed in the command prompt.
  45. :: Add, remove, or change options to reflect your own.
  46. ECHO. 1. TV
  47. ECHO. 2. HEADSET
  48. ECHO. 3. SPEAKERS
  49. ECHO.
  50. choice /C 123 /M "Select : "
  51. goto menu%errorlevel%
  52.  
  53. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  54. :: ("D:\Prog\audio\VAC\nircmdc") -- change "nircmdc" directory to wherever you have it installed (eg:"C:\Program Files\audio device")..
  55. :: (setdefaultsounddevice "TV" 1) -- is the audio device nircmdc selects as the default. must be spelled exactly the same as it is in windows (Control Panel\Hardware and Sound\Sound)..
  56.  
  57. :: (setsysvolume 13107) -- is a nircmdc option that sets the volume for a device. 13107 is %20 volume, 32768 is %50, 65535 is %100 volume..
  58. :: (ECHO Default audio device set to TV.) -- anything afer "ECHO" is just text that the command prompt displays, can be changed to whatever you want..
  59.  
  60. :: commands seperated with "&"(run previous command then this), "&&" (only run this if previous command is successful), "||" (only run this if previous command fails)..
  61. :: if there are any spaces in a command they must be enclosed in quotes (eg: "C:\Program Files\nircmdc" or "Line 1").
  62. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  63. :menu1
  64. "D:\Prog\audio\VAC\nircmdc" setdefaultsounddevice "TV" 1 & "D:\Prog\audio\VAC\nircmdc" setsysvolume 13107 "TV" &
  65. ::"D:\Prog\audio\VAC\nircmdc" setdefaultsounddevice "Microphone" 1 &
  66. cls
  67. ECHO.
  68. ECHO Default audio device set to TV.
  69. ECHO.
  70. goto start
  71. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  72. :menu2
  73. "D:\Prog\audio\VAC\nircmdc" setdefaultsounddevice "Headset" 1 & "D:\Prog\audio\VAC\nircmdc" setsysvolume 65535 "Headset" &
  74. ::"D:\Prog\audio\VAC\nircmdc" setdefaultsounddevice "Microphone" 1 &
  75. cls
  76. ECHO.
  77. ECHO Default audio device set to HEADSET.
  78. ECHO.
  79. goto start
  80. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  81. :menu3
  82. "D:\Prog\audio\VAC\nircmdc" setdefaultsounddevice "Speakers" 1 & "D:\Prog\audio\VAC\nircmdc" setsysvolume 13107 "Speakers" &
  83. ::"D:\Prog\audio\VAC\nircmdc" setdefaultsounddevice "Microphone" 1 &
  84. cls
  85. ECHO.
  86. ECHO Default audio device set to SPEAKERS.
  87. ECHO.
  88. goto start
  89. ::  -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
  90. ::- :menu4
  91. ::- :menu5
  92. :menu0
  93. goto start
  94. :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement