Auto run action when a new user loges on / add setting to HKEY_CURRENT_USER

Ever wanted to set a registry key to automate some stuff for your users, only to find out that the key resides in HKEY_CURRENT_USER making it quit difficult to have it work for all users on the pc. You can of cause set this in your login script, but setting registry fixes is not really a job for the login script.

During a deployment scenario, where only the administrator is logged in, we can obviously us the run once command from the registry, but that only run once on the computer, and not once pr. USER. We could also manipulate the NTUSER.DAT file and add settings there, but not all settings from ntuser.dat is transferred to the current user.

What we could do is to create an entry in the “HKEY_LOCAL_MACHINESOFTWAREMicrosoftActive SetupInstalled Components” key. Basically the entrees in this key is the stuff you se in the upper left hand corner during first log on. (the Personalized Settings box). Most if not all entries in this key will be in the GUID format, but it does not have to be..

Open REGEDIT and follow the instructions below.

image Right click Installed Components and click New KEY, and name the key {Z-UserSetup}.

NOTE: The different keys are executed in number and alphabetical order, so to make sure our key is executed last we name it Z-“something” and put it in { }. Everything not in curly braces wile be executed first.

image In the new key create two new String Values (REG_SZ) and name them
StubPath and Version.

StubPath has info on what we want to run, and could be any executable, script, run.dll e.t.c.

Version will show in the Installed Components section in CURRENT_USER

(Default) will be the info showed in the Personalized settings box during logon. (can also be sat as @=”info”)

 

Now just reboot and log on with a different user, and notepad will be executed during logon.

If you want to set this with a script ,then here small one for disabling the Windows Media Player wizard.


Set oShell=CreateObject("WScript.Shell")

RegPath="HKEY_LOCAL_MACHINESOFTWAREMicrosoftActive SetupInstalled Components{Z-UserSetup}"
oshell.RegWrite Regpath & "Stubpath", "reg.exe add HKCUSOFTWAREMicrosoftMediaPlayerPreferences _
/v AcceptedPrivacyStatement /t REG_DWORD /d 1 /f", "REG_SZ"
oshell.RegWrite Regpath & "Version", "1.00", "REG_SZ"
oshell.RegWrite Regpath & "@", "Accept MP Privacy Statement", "REG_SZ"


You can add as many entrees as you want, just be aware of the execution order.

Advertisements
This entry was posted in Tips and Tricks. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s