Updating every profile's registry on Windows Server 2003

ぃ、小莉子 提交于 2019-11-26 11:40:34

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/1423687/updating-every-profiles-registry-on-windows-server-2003

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!