Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dxsound.bat

(view source code of dxsound.bat as plain text)

  1. @ECHO OFF
  2. :: Check Windows version
  3. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  4.  
  5. :: Check if XML Starlet is available
  6. XML.EXE --version >NUL 2>&1 || GOTO Syntax
  7.  
  8. :: Check command line arguments
  9. ECHO.%* | FIND "?" >NUL
  10. IF NOT ERRORLEVEL 1 GOTO Syntax
  11. IF NOT "%~1"=="" IF /I NOT "%~1"=="/F" GOTO Syntax
  12.  
  13. :: If /F switch is used, an existing DxDiag generated XML file will be deleted
  14. IF /I "%~1"=="/F" IF EXIST %~sdpn0.xml DEL %~sdpn0.xml
  15.  
  16. :: If there is no DxDiag generated file available, create a new one (may take a minute)
  17. IF NOT EXIST %~sdpn0.xml DXDIAG.EXE /whql:off /x %~sdpn0.xml
  18.  
  19. :: Loop through our selection of properties . . .
  20. FOR %%A IN (Description HwAccelLevel DefaultSoundPlayback DefaultVoicePlayback) DO (
  21. 	SET Count=0
  22. 	REM Use the -m XPATH expression to select the proper XML nodes; then
  23. 	REM use the -v XPATH expression to return the desired property value
  24. 	FOR /F "tokens=*" %%B IN ('XML.EXE sel -B -I -T -t -m "/DxDiag/DirectSound/SoundDevices/SoundDevice" -v "%%A" -n %~sdpn0.xml') DO (
  25. 		CALL :GetPropertyValue %%A "%%~B"
  26. 	)
  27. )
  28.  
  29. :: Display the results
  30. ECHO.
  31. ECHO %Count% instances:
  32. FOR /L %%A IN (0,1,%Count%) DO (
  33. 	ECHO.
  34. 	SET DxSound%%A 2>NUL
  35. )
  36.  
  37. SET Count=
  38. GOTO:EOF
  39.  
  40.  
  41. :GetPropertyValue
  42. :: SET DXSOUND[sound_index].[property_name]=[property_value]
  43. SET DxSound%Count%.%1=%~2
  44. SET /A Count += 1
  45. GOTO:EOF
  46.  
  47.  
  48. :Syntax
  49. ECHO.
  50. ECHO DxSound.bat,  Version 1.00 for Windows XP
  51. ECHO List a selection of properties for each sound device
  52. ECHO.
  53. ECHO Usage:  DXSOUND  [ /F ]
  54. ECHO.
  55. ECHO Where:     /F    forces DxDiag.exe to create a new XML file
  56. ECHO.
  57. ECHO Notes:  Results are displayed and saved in environment variables DxSoundX.PPP
  58. ECHO         (X is the index number of the sound device, PPP is the property name).
  59. ECHO         DxDiag.exe (native) is required to save DirectX data to an XML file.
  60. ECHO         The creation of the XML file may take a long time, so the batch file
  61. ECHO         will reuse it if available, unless the /F command line switch is used.
  62. ECHO         XML Starlet is required to read the XML file.
  63. ECHO         Download XML starlet from http://sourceforge.net/projects/xmlstar/
  64. ECHO.
  65. ECHO Written by Rob van der Woude
  66. ECHO http://www.robvanderwoude.com
  67.  
  68. IF "%OS%"=="Windows_NT" COLOR 00
  69.  

page last modified: 2024-02-26; loaded in 0.0207 seconds