DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

How to Add Registry Keys During a Configuration Manager OS Task Sequence

Add registry values to the deployed Windows installation by running a correctly quoted command after Setup Windows and ConfigMgr, then verify the result in the right hive and registry view.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To change the registry of the Windows installation being deployed, add a General → Run Command Line step after Setup Windows and ConfigMgr. A command that runs earlier may change Windows PE instead of the installed operating system.

Why the task-sequence position matters

Configuration Manager task sequences can run commands in Windows PE, the temporary preinstallation environment, or in the full Windows operating system being deployed. A registry command writes to the environment in which it runs. Microsoft describes Setup Windows and ConfigMgr as the transition from Windows PE to the new operating system; after Windows Setup completes, the task sequence resumes in the full OS. See Microsoft’s task-sequence step documentation.

As an Amazon Associate I earn from qualifying purchases.

For a normal OS deployment, place the registry command after that transition. Editing an offline Windows registry hive before the transition is a different approach and is not needed for an ordinary machine-level change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add a Run Command Line step

  1. Open the task sequence in the Configuration Manager console and open the Task Sequence Editor.
  2. Choose Add → General → Run Command Line.
  3. Move the new step below Setup Windows and ConfigMgr. It need not be immediately adjacent, but placing it nearby makes the execution phase clear and reduces the chance that a later deployment action will overwrite the value.
  4. Enter the command in the step’s Command line field. During testing, leave Continue on error disabled so a failed command is not silently treated as a successful deployment.
  5. Run a test deployment, then verify the value in the installed operating system.

A typical sequence is:

Apply Operating System
Apply Windows Settings
Apply Network Settings
Setup Windows and ConfigMgr
Run Command Line - Add registry values
Install Applications / Configure Windows

The step is appropriate for unattended commands; it must not wait for input or open an interactive tool. Microsoft documents the Run Command Line action and its execution behavior at the task-sequence steps reference.

Build the registry command correctly

For a single value, use cmd.exe /c to run reg add. Quote the key path, especially if it contains spaces, specify the value name and type, and use /f to suppress the overwrite confirmation prompt.

Add a DWORD

cmd.exe /c reg add "HKLMSOFTWAREExampleProduct" /v Enabled /t REG_DWORD /d 1 /f

Add a string

cmd.exe /c reg add "HKLMSOFTWAREExampleProduct" /v SettingName /t REG_SZ /d "ExampleValue" /f

Choose a registry view when needed

On 64-bit Windows, an application may expect a value in a particular registry view. Specify /reg:64 or /reg:32 when that requirement is known rather than assuming the views are interchangeable:

cmd.exe /c reg add "HKLMSOFTWAREExampleProduct" /v Enabled /t REG_DWORD /d 1 /f /reg:64
cmd.exe /c reg add "HKLMSOFTWAREExampleProduct" /v Enabled /t REG_DWORD /d 1 /f /reg:32

Microsoft’s reg add reference documents its syntax, supported types, quoting for key names containing spaces, the two registry-view switches, and return codes: 0 indicates success and 1 indicates failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Examples from a Windows deployment question

These commands illustrate writing the values discussed in a historical Configuration Manager deployment thread; they are examples of registry writes, not a guarantee that the associated Windows behavior will be achieved:

cmd.exe /c reg add "HKLMSOFTWAREPoliciesMicrosoftWindowsStore" /v AutoDownload /t REG_DWORD /d 2 /f
cmd.exe /c reg add "HKLMSOFTWAREPoliciesMicrosoftWindowsCloud Content" /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f

The original poster reported that moving the commands to the post-setup portion resolved the registry-write issue. The thread is historical, covering SCCM 2012 and Windows 10; it also reports that the values did not prevent unwanted applications from downloading. Do not treat those commands alone as a current, universal application-control solution. See the original forum discussion.

Verify the write in the installed OS

Add a temporary verification step immediately after the write, or run the query after deployment. For example:

cmd.exe /c reg query "HKLMSOFTWAREPoliciesMicrosoftWindowsStore" /v AutoDownload

For the other example:

cmd.exe /c reg query "HKLMSOFTWAREPoliciesMicrosoftWindowsCloud Content" /v DisableWindowsConsumerFeatures

A successful query displays the value name, type, and data. Also check the Run Command Line step’s status and return code, then inspect smsts.log around that step if the result is unexpected. Confirm you are checking the installed OS, the intended registry view, and—if applicable—the intended user profile.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the right hive: HKLM or HKCU

HKLM is generally the relevant hive for machine-wide settings. HKCU refers to the current execution account’s profile, not automatically to every user who will later sign in. Task-sequence commands commonly run as Local System unless configured otherwise, so an HKCU write may affect the system account rather than the future interactive user.

For a per-user setting, choose an approach that matches when and for whom it must apply: configure the default user profile, apply it at first logon or in user context, use a policy-management mechanism, or load and edit the intended user’s NTUSER.DAT hive offline. The appropriate method depends on the setting and deployment design; a machine-context command is not a substitute for user-profile targeting.

Troubleshoot a value that is missing or does not stick

  • The step ran before the OS transition: move it after Setup Windows and ConfigMgr. A successful command in Windows PE does not establish that the installed OS was changed.
  • The key path contains spaces: put quotation marks around the complete key path, such as "HKLMSOFTWAREPoliciesMicrosoftWindowsCloud Content".
  • The value is in the wrong view: check the view the application uses and specify /reg:32 or /reg:64 if required.
  • The type or data is wrong: match /t to the expected registry type, such as REG_DWORD or REG_SZ, and confirm the data with reg query.
  • The task sequence appears to succeed despite a command error: check whether Continue on error is enabled. During troubleshooting, disable it and review the command’s return code; reg add returns 0 for success and 1 for failure.
  • The parent key is missing: reg add can create a key or value, but it cannot add an entire subtree in one operation. Create required levels separately or import a .reg file.
  • The value changes after the step: a later task-sequence action, installer, Group Policy, MDM policy, baseline, remediation, or first-logon action may set it again. A successful write is not proof that the value remains the final effective configuration. Microsoft notes that Group Policy normally processes after Windows Setup and the task sequence completes, although some task-sequence actions can trigger policy evaluation earlier.
  • The command blocks or restarts deployment unexpectedly: keep commands silent and unattended; use /f rather than relying on confirmation prompts. Do not restart the computer directly from the command. For a command that needs a restart, Microsoft says to return the standard code 3010 so Configuration Manager can manage the restart and resume the sequence.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When to use a script, a .reg file, or policy instead

Use direct reg add for a small machine-level change

For one or two values, a quoted reg add command in a post-transition Run Command Line step is easy to inspect and verify.

Use a .reg file for a related set of values

Package the file with the deployment content and import it silently:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cmd.exe /c regedit.exe /s Settings.reg

This keeps a larger group of settings together, but requires care with user hives, architecture, and file availability; an import can also make it less obvious which individual value failed. The original forum thread discusses packaging registry settings for import.

Use a CMD or PowerShell script for logic and error handling

A batch file can check the command result and return a failure code to the task sequence:

@echo off
reg add "HKLMSOFTWAREExampleProduct" /v Enabled /t REG_DWORD /d 1 /f
if errorlevel 1 exit /b 1
exit /b 0

For multiple values, conditions, or structured error handling, a packaged script can be easier to maintain than a long command line. A PowerShell equivalent for a DWORD is:

New-Item -Path 'HKLM:SOFTWAREExampleProduct' -Force | Out-Null
New-ItemProperty -Path 'HKLM:SOFTWAREExampleProduct' -Name 'Enabled' -PropertyType DWord -Value 1 -Force | Out-Null

Ensure scripts run silently and unattended in the intended execution context. Microsoft’s task-sequence documentation covers these requirements for command-line and PowerShell actions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use policy management when the setting must be enforced

If a registry value represents a Windows policy that must remain enforced, apply it through the appropriate Group Policy, Intune policy, Settings Catalog, policy CSP, or other management mechanism when available. Policy management is better suited to settings that must apply to multiple users, be reapplied after drift, change without reimaging, or vary by device group. A one-time task-sequence registry write does not itself provide ongoing enforcement.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.