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_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed 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.
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_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{Z-UserSetup}\" oshell.RegWrite Regpath & "Stubpath", "reg.exe add HKCU\SOFTWARE\Microsoft\MediaPlayer\Preferences" _ & "/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.
Ah thanks so much Michael, was trying to find a way to do this sort of ‘Run Once’ ordeal purely for new users. This was it, and exactly the same problem I was trying to solve (WMP Privacy). I had a bit of trouble finding this post from the last one which mentioned Active Setup, but google helped out.
Thanks!
Your welcome
Hi Michael
Thanks for the script, but I’m still having a little trouble.
(32bit windows 7 client)
Any ideas as to what I’m doing wrong. When I run your script it adds your registry entries fine, but when I run Media Player the welcome wizard still appears. On checking the registry HKCUsoftwaremicrosoftpreferencesAcceptedPrivacyStatment the value is still 0
any ideas?
Paul, just to be sure — you are creating a *new* user afterwards and logging into that one correct? This script will not adjust any existing users.
Fantastisk !!!
Tak Michael – dette har sparet mig for mange timers arbejde.
Mvh
Martin Warner
Hi Michael,
Thank you for the information provided. Im running (Windows 7 Professional) the script which generates the following error:
WshShell.RegWrite (6, 1) : Invalid root in registry key “HKEY_LOCAL_MACHINESOFTWAREMicrosoftActive SetupInstalled Components{Z-UserSetup}Stubpath”.
Any Idea ?
Thank you very much
Hi Michael, It’s me again, I just wanted to post the script I have which generates the error mentioned before.
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 & “Stubpath”, “reg.exe add HKCUSOFTWAREMicrosoftMediaPlayerPreferences /v AcceptedEULA /t REG_DWORD /d 1 /f”, “REG_SZ”
oshell.RegWrite Regpath & “Stubpath”, “reg.exe add HKCUSOFTWAREMicrosoftMediaPlayerPreferences /v FirstRun /t REG_DWORD /d 0 /f”, “REG_SZ”
oshell.RegWrite Regpath & “Version”, “1.00”, “REG_SZ”
oshell.RegWrite Regpath & “@”, “Accept MP Privacy Statement”, “REG_SZ”
Ricardo,
You have to execute the script as a local administrator or else it can’t create the key.
Good Luck.
–Jim
If you are deploying Windows 7 64-bit then the path would be:
RegPath=”HKEY_LOCAL_MACHINESOFTWAREWOW6432NodeMicrosoftActive SetupInstalled Components{Z-UserSetup}”
Just ran into it myself and thought I would share 🙂
/Patrik