const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."

set shell=createobject("wscript.shell")
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

'Read the current settings 
strKeyPath = "SOFTWARE\Citrix\ICA Client\Engine\Configuration\Advanced\Modules\ICA 3.0"
strValueName = "VirtualDriver"
intret = oReg.GetStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strVirtualdriver)

'if the key exists then
if intret=0 then

	'look to see if BHAudio has already been added
	if instr(strvirtualdriver,"BHAudio") then
	
		wscript.echo "Current VirtualDriver already contains BHAudio."

	else

		'Append BHaudio to existing VirtualDriver string and write back
		strKeyPath ="SOFTWARE\Citrix\ICA Client\Engine\Configuration\Advanced\Modules\ICA 3.0"
		strValueName = "VirtualDriver"
		strValue = strVirtualdriver & ",BHAudio"
		oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
	
		strKeyPath ="SOFTWARE\Citrix\ICA Client\Engine\Configuration\Advanced\Modules\BHAudio"
		strValueName = "DriverNameWin32"
		strValue = "BHCommsProtocols.dll"
		oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
		oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

		strKeyPath ="SOFTWARE\Citrix\ICA Client\Engine\Configuration\Advanced\Modules\VirtualDriver"
		strValueName = "BHAudio"
		strValue = ""
		oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

		wscript.echo "VirtualDriver updated with BHAudio."

	end if



else

	wscript.echo "Citrix Client not installed."
	wscript.quit

end if


