Import .reg file into the Default user profile via command line

6,964

You need to mount the DEFAULT user profile first:

reg load HKLM\DEFAULT c:\users\default\ntuser.dat

Then you can import or add your settings to the newly created HKLM\DEFAULT branch: (It's really important your path in reg add doesn't have a trailing slash \)

REM Advertising ID disabled
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f

In your case, you can import a .reg file also - but you need to make sure you edit the .reg so that the paths are correct for your mount point:

regedit /s \\test.local\dfs\public\Deployment\Scripts\SetDefaults\Fix_An_app_default_was_reset_HKDU.reg

When you are done, unmount the DEFAULT registry hive:

reg unload HKLM\DEFAULT

Here is an example of a complete script I use to customize newly imaged Windows 10 computers, now that the 'CopyProfile' unattend.xml setting no longer works reliably. I couple this with other scripts, as well as a Windows 10 Provisioning Package.

@ECHO OFF
REM This script configured the DEFAULT user profile for all new users on the system

reg load HKLM\DEFAULT c:\users\default\ntuser.dat

REM Advertising ID disabled
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f

REM Enable SmartScreen
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AppHost" /v EnableWebContentEvaluation /t REG_DWORD /d 1 /f

REM Delivery optimization, disabled
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" /v SystemSettingsDownloadMode /t REG_DWORD /d 3 /f

REM Do not hide system tray icons
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /t REG_DWORD /d 0 /f

REM Show known file extensions
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f

REM Remove search bar and only show
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v SearchboxTaskbarMode /t REG_DWORD /d 1 /f

REM Disable Game DVR
reg add "HKLM\DEFAULT\System\GameConfigStore" /v GameDVR_Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" /v AppCaptureEnabled /t REG_DWORD /d 0 /f

REM Set Desktop Background
mkdir %SystemRoot%\Web\Wallpaper\TEST
xcopy \\test.local\dfs\public\deployment\Customizations\TEST_Background_HiRes.png %SystemRoot%\Web\Wallpaper\TEST /Q /Y
xcopy \\test.local\dfs\public\deployment\Customizations\test.theme %SystemRoot%\Resources\Themes /Q /Y
REM reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes" /v InstallTheme /t REG_SZ /d "C:\Windows\resources\Themes\test.theme" /f
reg add "HKLM\DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Personalization" /v ThemeFile /t REG_SZ /d "C:\Windows\resources\Themes\test.theme" /f

REM Set Start Menu folders
REM reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.unifiedtile.startglobalproperties\Current" /v Data /t REG_BINARY /d 02000000bf6447b3e68ad3010000000043420100cb320a07058691cc930524aaa30144c38401669ff79db187cbd1acd4010005bcc9a8a401248cac034489850166a081bacbbdd7a8a482010005ceabd3e90224daf40344c38a016682e58bb1aefdfdbb3c0005afe69e9b0e24de930244d5860166bf9d879bbf8fc6d4370005a08cac800b24d1fe0144b2980166aabdd0e1cceadfb9150005a08ffcc103248ad0034480990166b0b599dccdb097de4d0005c5cbce95042486fb0144f485016680c9ced4afd99ec4b50100c23c0100 /f

REM Fix App Default Reset Warning
regedit /s \\test.local\dfs\public\Deployment\Scripts\SetDefaults\Fix_An_app_default_was_reset_HKDU.reg

REM Disable suggesting apps in start
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SystemPaneSuggestionsEnabled /t REG_DWORD /d 0 /f

REM Disable VMWare Tools tray icon
reg add "HKLM\DEFAULT\SOFTWARE\VMWare, Inc.\VMWare Tools" /v ShowTray /t REG_DWORD /d 0 /f

REM Set Google as default search provider in IE
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes" /v DefaultScope /t REG_SZ /d {e913ede7-630e-4d2a-a6af-2b28e7ce735b} /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v DisplayName /t REG_SZ /d Google /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v FaviconURL /t REG_SZ /d https://www.google.com/favicon.ico /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v ShowSearchSuggestions /t REG_DWORD /d 1 /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v SuggestionsURL /t REG_SZ /d "https://www.google.com/complete/search?q={searchTerms}&client=ie8&mw={ie:maxWidth}&sh={ie:sectionHeight}&rh={ie:rowHeight}&inputencoding={inputEncoding}&outputencoding={outputEncoding}" /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v URL /t REG_SZ /d "https://www.google.com/search?q={searchTerms}&sourceid=ie7&rls=com.microsoft:{language}:{referrer:source}&ie={inputEncoding?}&oe={outputEncoding?}" /f

REM Finished
reg unload HKLM\DEFAULT
Share:
6,964

Related videos on Youtube

Clacers
Author by

Clacers

Updated on September 18, 2022

Comments

  • Clacers
    Clacers over 1 year

    My goal is to import specific registry program settings (e.g. CCleaner) into the Default user profile of an active system to make sure new users get a predefined configuration. I do not want to create a new installation image or use any commercial third party software.

    This is how to import a .reg file to another user's profile:

    runas /u:User "cmd.exe /k reg import C:\Test.reg"
    

    I adapted it to:

    runas /u:DefaultAccount "cmd.exe /k reg import C:\Test.reg"
    

    Error:

    1327: Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.

    So I changed the following Registry value to:

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
    "LimitBlankPasswordUse"=dword:00000000
    

    But there is still the same error although it works with any other User!

    So how to import a .reg file into the Default user profile via command line?

    • Ramhound
      Ramhound almost 6 years
      The default profile does not have a user account associated with it. The way you would go about this the correct way, is to apply the registry to a user account that does exist, then update the configuration of the default profile to match that user profile you changed. Here is more information on the default local accounts that exist.
    • magicandre1981
      magicandre1981 almost 6 years
      HKEY_LOCAL_MACHINE is system wide, no user change, so what you try doesn't work. You run into XY problem. What is your original issue that you try to solve by importing a reg file?
    • Clacers
      Clacers almost 6 years
      My goal is to import specific registry program settings (e.g. CCleaner) into the Default user profile of an active system to make sure new users get a predefined configuration. I do not want to create a new installation image or use any commercial third party software.
    • magicandre1981
      magicandre1981 almost 6 years
      again HKEY_LOCAL_MACHINE is system wide setting, so what you do makes no sense at all.
    • Clacers
      Clacers almost 6 years
      Yes, you are right but please take a look at the differences between the stored program settings in HKCU and HKLM. You'll see that programs are generally very particular about that.
  • Clacers
    Clacers almost 6 years
    Thanks for the help! But I have dozens of .reg files which are being automatically created through a batch file. I cannot change every one of them to edit the paths... Is there a way without editing the .reg files themselves?
  • Appleoddity
    Appleoddity almost 6 years
    Why can’t you modify the batch file to create different .reg files? You didn’t really describe your use case. I’m wondering if there isn’t a better solution to this problem all together.