To add a .reg file silently to your Windows registry, you can use the regedit command. As almost always, the /s parameter is for silent and /q for quiet.

regedit /s your-key.reg

In this post, you learned how to silently import a .reg file into your Windows Registry. This neat regedit.exe trick comes in handy quite often. The regedit.exe command is valid for Windows 11, 10, Windows Server 2022, 2019 and older.

Create and import registry keys and values silently with Powershell

A PowerShell method of creating registry keys and setting values is using the cmdlets New-Item and New-ItemProperty. Normally they are all but silent and output a lot of information, but you can pipe the output to NULL using Out-Null. This hides the output instead of sending it down the pipeline or displaying it.

See the following examples and their differences:

PS C:\Users\Jan Reilink> New-Item -Path HKCU:\Software -Name TestSoftware

Hive: HKEY_CURRENT_USER\Software

Name Property
---- --------
TestSoftware

PS C:\Users\Jan Reilink> New-ItemProperty -Path HKCU:\Software\TestSoftware -Name key -Value 0001 -Type DWORD

key : 1
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\TestSoftware
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software
PSChildName : TestSoftware
PSDrive : HKCU
PSProvider : Microsoft.PowerShell.Core\Registry

PS C:\Users\Jan Reilink>
PS C:\Users\Jan Reilink> New-Item -Path HKCU:\Software -Name TestSoftware | Out-Null
PS C:\Users\Jan Reilink> New-ItemProperty -Path HKCU:\Software\TestSoftware -Name key -Value 0001 -Type DWORD | Out-Null
PS C:\Users\Jan Reilink>

If needed, you can also call reg.exe from Powershell to import a .reg registry file silently:

# Assuming you're in the directory where the .reg file is located,
# otherwise change the path
Start-Process -NoNewWindow -FilePath "C:\Windows\regedit.exe" -ArgumentList "/s .\your-key.reg"

If you have spaces in your ArgumentList arguments, don't forget to place quotes around them and escape those quotes using a backtick `, see:

Start-Process -NoNewWindow -FilePath "C:\Windows\regedit.exe" -ArgumentList "/s `"C:\Users\Jan Reilink\dev\TestSoftware.reg`""

See Stack Overflow for an example.

Donate a cup of coffee
Donate a cup of coffee

Thank you very much! <3 ❤️

2 Comments

  1. Michael Pollard

    It’s not entirely silent, as it asks for administrator approval. I want to use this in a login script for computers that are not joined to the domain.

    • jkhjjk

      It used to be silent but suddenly, as of the last couple of weeks (SEPT2020) its now triggering UAC on Windows 10.

      For Windows 8+ you can use REG IMPORT instead

      So, previously, and for many years:

      regedit /s “registry-to-import.reg”

      now

      reg import “registry-to-import.reg”

Comments are closed