Hi All,

We have an issue where users do not get a printer set in Lotus Notes within a citrix desktop session. I have found that if I manuall copy a REG_SZ value from HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\UserSID\ to

HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\ this sets the printer within Notes. An example of the value is:

Name - Device

Type - REG_SZ

Value - Adobe PDF (from MURGLAP10101) in session 73,winspool,Ne22:

Is there any way to copy this key and paste it in the required location bearing in mind this will somehow have to resolve the usersid as well?




0 Comments   [ + ] Show Comments


Please log in to comment



You can do this with active setup.

Another trick I found with some software you can put the same key under HKLM and it will the work for all users, this you need to test.  Windows 7 when it reads the hives most programs combine the keyset settings that are under both HKLM and HKCU that are for that software.

Answered 04/01/2013 by: SMal.tmcc
Red Belt

  • for active setup
    search for active setup in the ninja search box and there is even more
  • Thanks for the links will have a look over them. Modifying hklm would not be an option unfortunately as the value I need to copy is each users session printer.
    • Yes you are correct, If the data you are trying to inject is constant, it may work and save you going thru active setup. On a test machine put the key under HKLM and see if it works with no key under the user hive. I have had about 80-90 percent success doing this. Windows and software a lot of times blends both keys sets together for one set of keys to read ignoring if they originated from HKLM or HKCU
      • If this value varies for each user you can always add a reg merge to their login scripts. Even Active setup will not be able to inject variable info that is user unique without some sort of scripting to create the unique keys
Please log in to comment

Are there multiple keys (SID's) listed in "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\" for each user or is there just one?

Answered 04/01/2013 by: M P
Purple Belt

  • Since it HKCU I would assume it would be only that current users sid. I have never seen others users SID's under the users hive, user hives do not know about other user hives
  • Just the one sid, relating to whatever user is logged on.
Please log in to comment

If the other scenarios do not work for you, you can use a script like this to manipulate the registry information in the keys you have described.  Basically, we look at the original registry path you gave (HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\) and enumerate all of its subkeys.  From there, we look through each of the subkeys for a value named "Device" that we can copy.  If the value is found, the equivalent value is created under the second path you gave (HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\) thus creating the desired results.  Let me know if you have any questions or run into any issues.


Option Explicit
On Error Resume Next
Const HKCU = &H80000001
Dim strComputer, objReg, strOrigPath, strNewPath, arrKeys, strKey, strPrinter

strComputer = "."
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\default:StdRegProv")
strOrigPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices"
strNewPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows"

objReg.EnumKey HKCU, strOrigPath, arrKeys
For Each strKey In arrKeys
    objReg.GetStringValue HKCU, strOrigPath & "\" & strKey, "Device", strPrinter
    If strPrinter <> vbNull Then
     objReg.SetStringValue HKCU, strNewPath, "Device", strPrinter
    End If

Set strComputer = Nothing
Set objReg = Nothing
Set strOrigPath = Nothing
Set strNewPath = Nothing
Set arrKeys = Nothing
Set strKey = Nothing
Set strPrinter = Nothing


There is another value under the second path named "UserSelectedDefault", so if that is necessary, you can add a "objReg.SetDWORDValue" line under the existing "objReg.SetStringValue" line for the "Device" value, and set the value to 1 like this:

objReg.SetDWORDValue HKCU, strNewPath, "UserSelectedDefault", 1

Answered 04/01/2013 by: M P
Purple Belt

Please log in to comment


Thanks for the script, this appears to work as required. Just need to incorporate it into a GPO for the terminal server users.

Many thanks


Answered 04/08/2013 by: AllyRussell
White Belt

Please log in to comment
Answer this question or Comment on this question for clarity