Add registry key via batchfile



The task of adding a registry key via a batch file is a common one for IT admins. It can be used to automate tasks on a system or to customize settings for a particular user or group. In this article, we will discuss the steps necessary to accomplish this task.

Before you begin, you must have the proper access rights to modify the registry. This typically requires local admin rights, or a user account with the proper permissions.

The first step is to create the registry key. This can be done with the reg.exe command. This command requires the registry path and the name of the key being created. For example, if you were creating the key “Software\\MyCompany\\MyProduct”, then you would use the following command:

reg add \Software\\MyCompany\\MyProduct\

Once the key has been created, you can then configure the desired settings. This is done with the reg add command, and requires the registry path, name of the value, and the data for the value being set. For example, if you were setting the value “AutoLaunch” to “1”, then you would use the following command:

reg add \Software\\MyCompany\\MyProduct\ /v AutoLaunch /t REG_DWORD /d 1

Once the value has been set, you can then save the changes to the registry. This is done with the reg save command, and requires the path of the registry key, and the name of the file the changes will be saved to. For example, if you were saving the changes to the file “settings.reg”, then you would use the following command:

reg save \Software\\MyCompany\\MyProduct\ settings.reg

At this point, the settings have been saved to the file. The next step is to create the batch file. This is done with the same commands that were used to create and configure the registry, but with a few changes. First, the reg.exe command needs to be placed in quotes, so that the command line interpreter does not interpret the command as multiple commands. Second, you need to add the /s switch, which tells the command line to run the command in silent mode. Finally, you need to add the command to run the file that was created with the reg save command. For example, if you were using the file “settings.reg”, then the batch file would look like this:

@echo off
\reg.exe\ add \Software\\MyCompany\\MyProduct\
\reg.exe\ add \Software\\MyCompany\\MyProduct\ /v AutoLaunch /t REG_DWORD /d 1 /s
\reg.exe\ save \Software\\MyCompany\\MyProduct\ settings.reg /s
reg import settings.reg

This batch file will create the registry key and values, save them to the file “settings.reg”, and then import the file into the registry. The result is that the settings have been applied to the system.

Adding a registry key via a batch file is a simple task that can be used to automate tasks or customize settings on a system. With the proper access rights, it can be used to quickly and easily make changes to the registry.

Inquire Now

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Find your next full or part-time role here

ScaleDesk can either help you find your next full time gig or a part time side gig where you can create extra income!

Onboard with us once
Skip HR screening and go to the final interview with with only your resume and a video interview you never have to redo
Get paid electronically every month for the hours you work
We will be your reference even if you work for us once

IT Teams: Use ScaleDesk to augment your team

Schedule Demo