1 Reply Latest reply on Jun 10, 2020 5:50 AM by MaxStr

    Vmware Blast - Script to change microphone audio quality to 16khz - Workaround

    serinfbco Novice

      Hello,

       

      I'm been searching a way to set back the 16khz audio quality on Vmware Blast / Devtap driver.

      This KB tells that the driver sets back to 8khz, which is bad audio quality for video conference such as teams or zoom meetings : VMware Knowledge Base

       

      I used Regshot to pinpoint where it stores the settings about 16khz and it is in the keys  @ HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture

      To make this difficult, the GUIDs are not the same, so you have to search the subkeys to know if it's the Blast driver such as " XXX (VDI)" or "Vmware Audio ...."

       

      So I made a script that changes some hexdata, the difference between 8khz vs 16khz settings.

      Strangely, this is secured by Microsoft as SYSTEM account has no rights, also you get denied access from powershell script and reg.exe (even UAC elevated)

      You need to use credentials as an administrator/UAC with regedit.exe /s ... so the script writes back the values with the modified parts.

       

      I made this stuff yesterday and it's pretty draft/rough... so you might test it before production env. It touches the registry deeply, use at your own risk.

       

      You have to create a scheduled task on logon that calls this script. Didn't test GPO way.

      Tested on Windows 10 Education 1809 64-bit, Vmware Horizon View 7.12, may works with other versions.

       

       

       

      Const HKEY_LOCAL_MACHINE = &H80000002
      strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Capture"
      Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
      Set objShell = WScript.CreateObject ("WScript.shell")
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Const ForReading = 1, ForWriting = 2, ForAppending = 8
      
      
      strLogFolder = "C:\folder"
      Set objLogFile = objFSO.OpenTextFile( strLogFolder & "\audio.reg", ForWriting, True)
      objLogFile.WriteLine "Windows Registry Editor Version 5.00"
      
      
      'WScript.Echo key
      oreg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
      If Not IsNull(arrSubKeys) Then
          For Each subkey In arrSubKeys
              'WScript.Echo subkey
              subkeypath = strKeyPath  & "\" & subkey & "\Properties"
              oReg.GetStringValue HKEY_LOCAL_MACHINE, subkeypath, "{b3f8fa53-0004-438e-9003-51a46e139bfc},6", strValue
          'wscript.echo strValue
              if instr(strValue, "VDI") > 0 OR instr(strValue,"Vmware") > 0 then
                  objLogFile.WriteLine "[HKEY_LOCAL_MACHINE\" & subkeypath & "]"
                  write_registry subkeypath,"{f19f064d-082c-4e27-bc73-6882a1bb8e4c},0"
                  write_registry subkeypath,"{3d6e1656-2e50-4c4c-8d85-d0acae3c6c68},3"  
                  write_registry subkeypath,"{e4870e26-3cc5-4cd2-ba46-ca0a9a70ed04},0"  
                  write_registry subkeypath,"{624f56de-fd24-473e-814a-de40aacaed16},3"  
                  write_registry subkeypath,"{3d6e1656-2e50-4c4c-8d85-d0acae3c6c68},5"  
                  write_registry subkeypath,"{3d6e1656-2e50-4c4c-8d85-d0acae3c6c68},9"
              end if
      
      
          Next
          objLogFile.close
          objShell.run "cmd /c regedit.exe /S "& strLogFolder &"\audio.reg",0,true
      End if
      
      
      function write_registry(subkeypath_wr, dataname_wr)
      
      
          dataname = dataname_wr
          subkeypath = subkeypath_wr
          'wscript.echo subkeypath 
          oReg.GetBinaryValue HKEY_LOCAL_MACHINE,subkeypath,dataname,arrBytes
      
      
          If IsNull(arrBytes) Then
              'Wscript.Echo "The registry key does not exist."
           Else
              'Wscript.Echo "The registry key exists."
              For Each uByte in arrBytes
                  'wscript.echo Hex(uByte)
                  strBytes = strBytes & Hex(uByte) & ","
              Next
      'wscript.echo strBytes
              strBytes = left(strBytes,len(strBytes)-1)
              'wscript.echo strBytes
              splt_strBytes = split(strBytes,",")
              splt_strBytes(12) = "80"
              splt_strBytes(13) = "3e"
              splt_strBytes(14) = "0"
              splt_strBytes(15) = "0"
              splt_strBytes(16) = "0"
              
              if dataname = "{f19f064d-082c-4e27-bc73-6882a1bb8e4c},0" then
                  splt_strBytes(17) = "7d"
              else
                  splt_strBytes(17) = "fa"
              End If
              
              Hexdata = ""
              
              for each strByte in splt_strBytes
                  Hexdata = Hexdata & strByte & ","
              next
              
              Hexdata = left(Hexdata,len(Hexdata)-1)
              objLogFile.WriteLine """" & dataname & """=hex:"& Hexdata
              'wscript.echo Hexdata
              'wscript.echo "cmd /c reg add ""HKLM\" & subkeypath & """ /v """ & dataname & """ /t REG_BINARY /d " & Hexdata & " /f"
              'objShell.run "cmd /c reg add ""HKLM\" & subkeypath & """ /v """ & dataname & """ /t REG_BINARY /d " & Hexdata & " /f",0,true
          End If       
      
      
      end function