1

I have a Windows Server 2003 system that is used for terminal services. We do not use roaming profiles. We do not use login scripts. I have about thirty to fourty accounts that log into this system and as such have local profiles.

One of the software packages that are installed onto this system uses HKCU/Software reg tree for its licensing and so each user has the license key in their local profile.

How can I update all of these different profiles registries in a deterministic manner?

Ian
  • 13
  • 3

2 Answers2

1

Active Setup is no longer advisable (original source).


There are several ways to achieve what you want - one clunkier than the other. Terminal servers can be a deployment nightmare - users may not have rights to run msiexec.exe and hence MSI self-repair could fail. That's why I generally prefer to use batch files, scripts or reg files for the kind of situation you are facing.

I would use Microsoft's Active Setup feature. This is just a fancy name for a feature which allows you to "run something once per profile on login". Here is a good explanation: http://www.etlengineering.com/installer/activesetup.txt

Here is a sample active-setup entry for an MSI file (this is the content of a *.reg file):

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\[ProductCode]]
"StubPath"="[SystemFolder]msiexec.exe /q /fou [ProductCode]"

The "StubPath" command can be anything "runnable", and in your case I would suggest not running msiexec.exe but rather a vbscript via cscript.exe or some other batch mechanism (CMD, REG, Etc...). The reason is what I stated above: msiexec.exe may not be allowed to run for terminal server users. In other words, something like this:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\MyProduct]
"StubPath"="[SystemFolder]cmd.exe /k C:\SomeScript.cmd"

There are other ways to add data to each user's profile such as using advertised MSI shortcuts and self-repair, but I wouldn't recommend that for terminal servers. See this serverfault.com answer for information on problems with the use of MSI files for registry settings.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
0

Mount the registry hive programatically, change the keys, then close the hive. Alternatively, you could use PSExec/runas to run the "update the keys" script as that user, which also solves the "edit HKCU" problem

Ana Betts
  • 73,868
  • 16
  • 141
  • 209
  • How do you mount all the hive's programatically? I haven't found out how to do that yet. – Ian Sep 16 '09 at 13:39
  • 1
    Wouldn't recommend this - you have no business updating any user profiles "out of context" like this. Side effects are likely and consequences unpredictable. – Stein Åsmul Apr 22 '11 at 23:49