Jump to content




roshanbhavsar04

How can I change a HKCU setting within Windows during an OSD deployment



Recommended Posts

Hey TechGuys,

 

can anybody help to write a script for windows xp computers set " adjust for best performance" in computer properties. I need to make a deployment this package over 300+ computers in our office.

 

 

-Roshan

Share this post


Link to post
Share on other sites


some updates on developments

 

Reg ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" /V VisualFXSetting /T REG_DWORD /F /D 2 - these are the content from batch file and it works well but I need to run it using a vbscript silently -

 

I tried it using -

 

set wshell = CreateObject("WScript.Shell")
wshell.run “PCVIS.bat"
set wshell = nothing

 

but its not working :(

Share this post


Link to post
Share on other sites

you are trying to apply settings to the Current User section of the registry which won't work during a task sequence as the task sequence runs for Computers not users,

you can get around this by mounting the registry hive for the Default User, making the changes using your chosen registry file which is pointing to this mount point, then commit the changes,

 

what this will mean is that All new user profiles on that computer will get the change, here's an example of that for a Windows 7 deployment (you will need to adjust accordingly for Windows XP so that C:\Users becomes C:\Documents and Settings\)

 

Below is an example for modifying HKCU settings for Windows 7

 

the first step will Load the Default User registry hive into a mountpoint called Defuser using a Run Command Line step like so

cmd.exe /c reg.exe load HKEY_LOCAL_MACHINE\defuser c:\users\default\ntuser.dat
 

in the next step we import the Registry file in another Run Command Line step this Registry file can be a file in a package.

cmd.exe /c reg.exe import "Userprefs.reg"
 

the important thing here is that the registry file refers to the mountpoint referenced in our first step, below is an example of that

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MediaPlayer\Preferences]
"AcceptedEULA"=dword:00000001
"FirstTime"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer]
"GroupPrivacyAcceptance"=dword:00000001

;Change start Page to windows-noob
[HKEY_LOCAL_MACHINE\defuser\Software\Microsoft\Internet Explorer\Main]
"Start Page"="http://www.windows-noob.com"
"Default_Page_URL"="http://www.windows-noob.com"

;Add documents on desktop add My computer 
[HKEY_LOCAL_MACHINE\defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel]
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}"=dword:00000000
"{59031a47-3f72-44a7-89c5-5595fe6b30ee}"=dword:00000000
"{871C5380-42A0-1069-A2EA-08002B30309D}"=dword:00000000

;Adds recent docs on startmenu
[HKEY_LOCAL_MACHINE\defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"Start_ShowRecentDocs"=dword:00000001

;Intellimenus
[HKEY_LOCAL_MACHINE\defuser\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"Intellimenus"=dword:00000001

; Remove Accept Eula for Adobe reader 
[HKEY_LOCAL_MACHINE\defuser\SOFTWARE\Adobe\Acrobat Reader\9.0\AdobeViewer]
"EULA"=dword:00000001
"Launched"=dword:00000001

; Remove Accept Eula for Adobe svg reader 
[HKEY_LOCAL_MACHINE\defuser\SOFTWARE\Adobe\Adobe SVG Viewer\3.03\EULA]
"3.03x94"="accepted"

;set blank screensaver with a ten minute timeout
[HKEY_LOCAL_MACHINE\defuser\Control Panel\Desktop]
"ScreenSaveActive"="1"
"SCRNSAVE.EXE"="C:\\Windows\\system32\\scrnsave.scr"
"ScreenSaveTimeOut"="600"
"ScreenSaverIsSecure"="1"

;Show extension for files
[HKEY_LOCAL_MACHINE\defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"HideFileExt"=dword:00000000
"SuperHidden"=dword:00000001

[HKEY_LOCAL_MACHINE\defuser\Software\Microsoft\Communicator]
"AutoRunWhenLogonToWindows"=dword:00000000
"FirstTimeUser"=dword:00000000
"TourPlayed"=dword:00000001

and finally we commit the changes in another Run Command Line step

cmd.exe /c reg.exe unload HKEY_LOCAL_MACHINE\defuser
 

and that's all there is to it, using this methodology you can set any HKCU keys you want to be applied during an OSD task sequence

cheers

niall

Share this post


Link to post
Share on other sites

First thing, thanks a lot for your prompt response

 

Indeed, i wanted to change "adjust pc for best performance" for current user profile only and not for entire computer.

 

can you please let me know If I can program this registry file in package?

 

and what needs to be done in - cmd.exe /c reg.exe import "Userprefs.reg"

 

I didn't get this command line, means where and how should I use it??

 

Desktop.zip

Share this post


Link to post
Share on other sites

userprefs.reg is just an example file name using the example registry file i posted above, simply replace the file name userprefs.reg with your OWN registry file,

 

you can create your own registry file by making the changes on your desired computer, and then exporting that registry key to a REG file.

 

Once you have the reg file edit it and replace all lines that begin with

 

[HKEY_CURRENT_USER\

 

with the following

 

[HKEY_LOCAL_MACHINE\Defuser\

 

below is an example of that.... I've created a Registry file in notepad called visualFXsetting.reg containing the following...

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects]
"VisualFXSetting"=dword:00000002
 

save that file and in the following step, refer to the new registry file which is simply ONE file in a package

 

cmd.exe /c reg.exe import "visualFXsetting.reg"

 

like below...

 

hkcu import user preferences.png

 

as this question is frequently asked and misunderstood i've changed the Topic title to be more descriptive of the actual problem.


Share this post


Link to post
Share on other sites

got it, I tried this command line in existing program but getting an error in execmgr

 

line - cmd.exe /c reg.exe import "pcvis.reg"

 

GetFileVersionInfoSize failed for file C:\WINDOWS\system32\CCM\Cache\TTG0028C.37.S-1-5-21-202387345-4201324245-3709672714-7083\cmd.exe, error 1812

Share this post


Link to post
Share on other sites

are you using the steps in a task sequence or just sending out a package 'job' to your computers....

Share this post


Link to post
Share on other sites

Let me give you a brief idea on this. we have a 200 computers in a dept and got the requirement to change paging file size, 3 GB switch and adjust pc for best performance and I have created a package for it.

 

rest of the things are works perfect but only the thing is reg file works after importing to computer manually.

Share this post


Link to post
Share on other sites

as per your suggestion I have edited export file and edited it.

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects]
"VisualFXSetting"=dword:00000002

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\AnimateMinMax]
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\ComboBoxAnimation]
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\CursorShadow]
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows]
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DropShadow]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\FontSmoothing]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\ListBoxSmoothScrolling]
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\ListviewAlphaSelect]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\ListviewShadow]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\ListviewWatermark]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\MenuAnimation]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\SelectionFade]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\TaskbarAnimations]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\Themes]

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\TooltipAnimation]
"DefaultValue"=dword:00000001
"DefaultApplied"=dword:00000001

[HKEY_LOCAL_MACHINE\Defuser\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\WebView]
"DefaultApplied"=dword:00000001

 

Share this post


Link to post
Share on other sites

if you are sending a package to a computer then that is a different case altogether, is a user logged on ? yes/no

 

are you running the package as a user or as a computer, if running in system context (computer) then only the HKLM changes will apply (as in your case)

 

you need to run it in User Context or use the workaround i've explained already... (you can run it in user context by deploying it to a device collection, with an Available purpose, and set the program to run as the current logged on user)

 

have you tried doing this via a task sequence only (you can create a custom task sequence to do these steps...)

Share this post


Link to post
Share on other sites

the reg file with Defuser references will only work as part of the workaround i provided.

when you manually run your file it works because you are a user and it's running it in user context,

when you run it as a package it's running in system context and therefore failing.

Share this post


Link to post
Share on other sites

use the workaround i already explained or try this.

Share this post


Link to post
Share on other sites

Hi, great thread on loading hte user hive. While the first two steps seem to work right (load the hive, apply the userpref.reg file) I'm running into a problem on the third step. My smsts.log file shows this error:

 

Executing command line: smsswd.exe /run: cmd.exe /c reg.exe unload HKEY_LOCAL_MACHINE\defuser c:\users\default\ntuser.dat TSManager 3/13/2014 2:47:58 PM 2768 (0x0AD0)
[ smsswd.exe ] InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
PackageID = '' InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
BaseVar = '', ContinueOnError='' InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
ProgramName = 'cmd.exe /c reg.exe unload HKEY_LOCAL_MACHINE\defuser c:\users\default\ntuser.dat' InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
SwdAction = '0001' InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Command line for extension .exe is "%1" %* InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Set command line: Run command line InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Working dir 'not set' InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Executing command line: Run command line InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Process completed with exit code 1 InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
ERROR: Invalid syntax. InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Type "REG UNLOAD /?" for usage. InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Command line returned 1 InstallSoftware 3/13/2014 2:47:58 PM 1712 (0x06B0)
Process completed with exit code 1 TSManager 3/13/2014 2:47:58 PM 2768 (0x0AD0)
!--------------------------------------------------------------------------------------------! TSManager 3/13/2014 2:47:58 PM 2768 (0x0AD0)
Failed to run the action: Run Command Line - Unload Default User Hive.
Incorrect function. (Error: 00000001; Source: Windows) TSManager 3/13/2014 2:47:58 PM 2768 (0x0AD0)

 

That invalid syntax is throwing me. I've looked up Reg.exe unload and it seems to be the proper syntax, but it's getting that error. Any thoughts?

 

Thanks!

Share this post


Link to post
Share on other sites

nevermind, i think i figured it out. It looks like on the unload you leave off the path to the ntuser.dat location and just use the key

cmd.exe /c reg.exe unload HKEY_LOCAL_MACHINE\defuser

Thanks for the walkthrough!

Share this post


Link to post
Share on other sites

correct and i've updated the typo !

Share this post


Link to post
Share on other sites

This step for me did not work with that command line, I kept on getting the 0x0000001 task sequence error.

 

"in the next step we import the Registry file in another Run Command Line step this Registry file can be a file in a package.

 

cmd.exe /c reg.exe import "Userprefs.reg"

 

but what is now working is:

 

regedit /s "NameOfYourRegFile.reg"

Share this post


Link to post
Share on other sites

you can run a package/program as the logged in user which should do what you want.

Share this post


Link to post
Share on other sites

Hello

 

I am trying to use the process you documented in MDT 2013 Update 1 on Windows 10 1511. I am finding that not all the keys in my import file are being applied to the new profiles. Below are some examples.

 

Privacy

;AccountInfo
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{C1D23ACC-752B-43E5-8448-8D0E519CD6D6}]
"Value"="Deny"
;Calendar
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{D89823BA-7180-4B81-B50C-7E471E6121A3}]
"Value"="Deny"
;CallHistory
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{8BC668CF-7728-45BD-93F8-CF2B3B41D7AB}]
"Value"="Deny"
;Camera
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{E5323777-F976-4f5b-9B55-B94699C46E44}]
"Value"="Deny"
;Email
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{9231CB4C-BF57-4AF3-8C55-FDA7BFCC04C5}]
"Value"="Deny"
;Location
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}]
"Value"="Deny"
;Messages
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{992AFA70-6F47-4148-B3E9-3003349C1548}]
"Value"="Deny"
;Microphone
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{2EEF81BE-33FA-4800-9670-1CD474972C3F}]
"Value"="Deny"
;Names
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{C1D23ACC-752B-43E5-8448-8D0E519CD6D6}]
"Value"="Deny"
;SyncWithDevices
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\LooselyCoupled]
"Value"="Deny"
Edge
;Edge Main Settings
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Main]
"DoNotTrack"=dword:00000001
"HomeButtonEnabled"=dword:00000001
"FormSuggest Passwords"="no"
"HomeButtonPage"="http:XXXXXXXXX"
;Edge New Tab
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\ServiceUI]
"NewTabPageDisplayOption"=dword:00000002
;Edge No First Run Page
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\TabbedBrowsing]
"NTPFirstRun"=dword:00000001
;Edge Page Prediction
[HKEY_LOCAL_MACHINE\Defuser\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\FlipAhead]
"FPEnabled"=dword:00000000

 

Any ideas why these would not get applied while others are successful?

Share this post


Link to post
Share on other sites

I did verify that the keys are being created correctly. I ran cmd.exe /c reg.exe load HKEY_LOCAL_MACHINE\defuser c:\users\default\ntuser.dat and opened defuser in the registry. The just didn't copy to the new profiles for some reason.

 

Thanks in advance!

Share this post


Link to post
Share on other sites

did you verify that the reg load, inject, reg unload steps (three) all completed successfully in smsts.log, using a pause as explained here will help

Share this post


Link to post
Share on other sites

Hello

 

A bit more background. I'm trying to get this working in MDT 2013 UD1 deploying Windows 10 Pro x64 1511. I originally found your site when I was trying to deploy a customized Start menu. In that thread you advised me to stop using CopyProfile which brought me here as i was looking for an alternative. I have not tried the pause script you referenced above but I'm not sure that it would help me.

 

I have created a .bat file with about 20 to 30 lines of HCKU settings in the following format.

 

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{C1D23ACC-752B-43E5-8448-8D0E519CD6D6}" /v "Value" /t REG_SZ /d "Deny" /f

 

I copy my .bat file to the Admin desktop and pause it right after running (As Admin) REG.EXE LOAD HKEY_LOCAL_MACHINE\Default C:\Users\Default\ntuser.dat. I open the registry and I can see the Default key and I then close registry. I let the .bat run and pause it again prior to REG.EXE UNLOAD HKEY_LOCAL_MACHINE\Default. Open the registry and expand Default. All my imported settings are present. So I finish the script, restart the PC and sign in with a new profile. Many of my new HKCU settings are there but about 1/4 are missing.

 

Examples of missing

REG ADD "HKEY_LOCAL_MACHINE\Control Panel\Desktop" /v "Wallpaper" /t REG_SZ /d "C:\Windows\Web\Wallpaper\MyWallpaper10\IMG_6900.jpg" /f (Still default Windows image)

Most all of the Privacy Keys

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{C1D23ACC-752B-43E5-8448-8D0E519CD6D6}" /v "Value" /t REG_SZ /d "Deny" /f (Still Allow)

REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\LooselyCoupled" /v "Value" /t REG_SZ /d "Deny" /f (Still Allow)

 

I'm stumped. CopyProfile was very handy but this would be ok if it worked. By the way... my custom start menu is now working as advertised.

 

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×