Windows 10

How to Add a Registry Key in a Batch File

In this tutorial, we are going to see how to add a registry key in a batch file. The batch file contains a series of DOS (Disk Operating System) instructions. It allows triggering the execution of commands found in this file.
 

Syntax
REG ADD [ROOT\]RegKey /v ValueName [/t DataType] [/S Separator] [/d Data] [/f] 

 

 

How to Add a Registry Key in a Batch File

The following example add a registry key:

@echo off

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList" /v "MyCustomWorkgroupUsername" /t REG_DWORD /d 0
  • use reg add command to add a new registry key,
  • specify as “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList”,
  • specify the name of the registry key as “MyCustomWorkgroupUsername”,
  • specify the type as REG_DWORD (a string), and
  • specify the data (key’s value) as 0

 

Leave a Reply

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