We help IT Professionals succeed at work.

Script to add default sound card settings for new users

ditobot asked
I have an audio PC running Windows XP SP3 that has a multi-input sound card and I need to create a logon script that will set the proper default values. I am savvy enough to edit pre-existing scripts but am very limited in my scripting abilities.

I have sort of stumbled half way onto the proper script but I am having problems createing the entire structure in the registry. Apparently the Sound Mapper settings don't get created in the registry until the user goes into control panel and changes what comes up by default so it appears that I will have to create the entire Sound Mapper registry directory for new users.

So far I have a script to add the proper strings for my sound card but I can't figure out how to add the proper REG Dword values to complete the field.

Here is what the completed registry directory should look like:

HKCU/Software/Microsoft/Multimedia/Sound Mapper:

(Default)                                            REG_SZ            (Value Not Set)
ConsoleVoiceComPlayback                REG_SZ            LynxONE Digital Out
Playback                                            REG_SZ            LynxONE Digital Out
PrefferredOnly                                   REG_DWORD    0x00000000(0)
Record                                               REG_SZ            LynxONE Digital In
SetupPreferredAudioDevicesCount   REG_DWORD    0x00000000(0)

I have managed to find a script that will add REG_SZ values, one at a time but I would prefere a script that would create everything in one script. Here is the script I am using to create a single REG_SZ value.

strSetTo = "LynxONE Digital Out"

Set wshShell = CreateObject("WScript.Shell")
strRegVal = "HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\Playback"

strSetting = ""
On Error Resume Next
strSetting = wshShell.RegRead(strRegVal)
On Error Goto 0

If strSetting <> strSetTo  Then
    wshShell.RegWrite strRegVal, strSetTo
End If

If there is a better way to go about setting default audio card settings for all users on a single machine then I am all ears. Either way, thanks in advance for any help.
Watch Question

Paste the script below into a text file with a .vbs extension.  Running it will set the desired values.

Note that I corrected the spelling of "Preferred".  If the software actually does spell it "PrefferredOnly" then modify line 15 accordingly.

Const HKEY_CURRENT_USER = &H80000001

strKeyPath = "Software\Microsoft\Multimedia\Sound Mapper"

Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
objRegistry.CreateKey HKEY_CURRENT_USER, strKeyPath
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath,_
    "ConsoleVoiceComPlayback", "LynxONE Digital Out"
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath,_
    "Playback", "LynxONE Digital Out"
objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath,_
    "Record", "LynxONE Digital In"
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath,_
    "PreferredOnly", 0
objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath,_
    "SetupPreferredAudioDevicesCount", 0

Open in new window


That did the trick, unfortunately my sound card didn't entirely like me setting the Sound Mapper settings. It is a finicky sound card and I might just be stuck with the cumborsome task of setting up each user individually.