Volume and Mute not beeing saved in a XenApp or VDI Session

UPDATE: Citrix obviously liked my idea and released their own tool with the same functionality. https://support.citrix.com/article/CTX206888 – it just lacks the Delay Options, but the binary does pretty much the same. oh well… i should have copyrighted it before 😛

i should have written this article already long time ago, but instead i just posted to some Citrix forums and gave out a link to my little tool. a few people already downloaded it and its probably used in quite some environments over the world. anyway – here comes finally a proper blog post about it.

the problem:

since Windows Server 2008 the volume level and mute settings are not roamed anymore. this is not Citrix fault, but Microsoft decided to remove that feature and now the volume level is always set to 100% when a user logs on. even when reconnecting the audio volume gets maximized and mute disabled. this can be annoying in environments that need sound for their work. all windows versions higher than Vista do have this problem – means all Windows versions with the new audio subsystem.

it seems, that these settings are not stored in the registry – at least i was not able to find where and all i have found were some workarounds, but never a full complete solution.

one of my customers reported the same problem on a XenApp 6.5 and Windows 2008 R2 farm and since was not able to find a proper solution, i have coded a little tool that saves these settings in the registry and then loads them again on a login or reconnect. i have found some helpful source code online which hooked into the volume slider and from there i was able to get the actual settings.

the principle of my tool is pretty simple: it starts when the users logs on and then it runs in the background – watching the volume settings. as soon a user touches the volume slide or enables mute, the tool will write these settings to the registry. following keys are used:

HKEY_CURRENT_USER\Control Panel\Sound
Volume: the actual volume level. range: 0.000000 to 1.000000
Mute: mute level on or off. value: true or false
ReconnectTimer: this is a hidden setting, where a timer will delay the audio setting restore when a user reconnects to a session (in milliseconds)

so if your environment for some reason does need additional time to initialize the session and the volume restauration does not work, you can try to set ReconnectTimer in the registry to give it a little more time.

the same feature is available, when you start the volume.exe – it takes a commandline parameter (time in milliseconds) and will wait the supplied time until it restores the volume from the registry settings.

there is no GUI or configuration option – the tool just does, what it should.

implementation:

i prefer to implement it in a windows GPO using the logon script section, but some customers used the startup folder or an existing logon script to launch it – this also seems to work fine.

gpo_logon_script

 

volume_script

in this case it would wait 2 seconds until it restores the volume settings from the registry.

published apps:

i personally never used it with published apps, but thanks to Bernd Nömer who gave a helpful tipp in the citrix forums:

The only thing you should do is placing the volume.exe in the “LogoffCheckSysmodules” Reg.Key so that the volume.exe will be closed when using published Apps!

Windows Server 2012 R2 and XenApp 7:

Microsoft added some questionable default setting in Server 2012 R2 and Windows 8.1 – the logon script delay. if you dont disable this feature, the loginscript will delay 5 minutes and the volume.exe does not run properly. just disable the policy to fix that:
Computer Configuration\Administrative Templates\System\Group Policy\Configure Logon Script Delay.

logon_script_delay

thats it – now the users volume settings are all saved and restored in XenApp sessions. of course you need a roaming profile solution and save the registry keys mentioned above.

additional info:

i have tested this utility on Server 2008 R2 and Server 2012 R2, but it should work on any OS newer than Vista. you will see the volume.exe process for every user on your XenApp server – dont worry, the binary is only 188 KB and it will take about 1.6MB RAM for each user. you can of course use a seperate policy and therefore limit the instances to a group, when for example not all users in your farm use audio.

the utility is coded in visual c++ 2010 express and is based on these code references:

https://subversion.assembla.com/svn/snarl-audiomon/trunk/snarl-audiomon.cpp
http://support.microsoft.com/kb/310153/en-us
http://blogs.msdn.com/b/calvin_hsia/archive/2006/01/11/511639.aspx
http://www.eventghost.org/forum/viewtopic.php?f=4&t=271

download:

you can download the volume.exe here: volume – the SHA1 for the volume.exe is 1EA3248E541D8B7AA035BA73CCE09A46DC797351

if you enjoyed my work, consider donating. I would appreciate it very much!

 

BTC: 1G7HETp7j5dq422mTg1VNB1yph9m3eKgX1
LTC: LdmnKE7SnKAzKPrs6MrrPFXskuP1qRVBcD
ETH: 0x89c83770e89ae08e856EE239e477BC758FCf3Bf8
XMR: 47y7gzD2DmjSBhKyaxQ2C7RUpLgwzr2hYGu2Ui6NcAi2feChfVR99nhBvJPQxPqhEpRfuy9pAr5ypghETPWQ3MQGCdYSK3u
PayPal: https://www.paypal.me/Kolbicz

 

Thank you!

8 Comments

    • hey there. the utility is not supposed to be open-source, but i have linked the most important source codes in the article – you should be able to rebuild a similar tool based on these sources 🙂

  1. Hi Christophe,

    Thanks for the article. Do you happen to have any links to Microsoft articles or blogs which detail the removal of this feature? I need to “sell” this to my client but can’t find any official statements surrounding this.

    Many thanks.

    • hey! sorry for the long delay… i was on vacation. actually i never found this documented somewhere… but it worked before windows 2008. dont know why microsoft removed that feature, but they implemented a new audiostack in vista kernel – maybe thats why.

  2. Thank you for this. I am using XenDesktop, I have put the EXE on the image and I have it run at startup. I have it so that the registry settings are captured at logoff but when the user signs on it still goes to 100%

    What did I miss?

  3. I see that the volume for the speakers is zero. Now I push it to the max volume. But after every restart, I have to open alsamixer again and have to set the volume to max again. Can I save the settings for alsamixer or is there any other way to fix the problem ?

Leave a Reply