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
# or written out in full
# & C:\Windows\regedit.exe /s your-key.reg 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.
Change IIS’ version number in the registry and install URL Rewrite Module successfully
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> Silent registry key import using PowerShell
Method 1, straightforward
Start-Process -NoNewWindow "C:\Windows\regedit.exe" -ArgumentList "/s your-key.reg" Method 2, more extensive:
$arguments @(
"/s",
"your-regkey.reg"
)
$process = Start-Process -NoNewWindow "C:\Windows\regedit.exe" -ArgumentList $arguments -PassThru -Wait
$process.WaitForExit()
if($process.ExitCode -ne 0 -and $process.ExitCode -ne 3010) {
Throw "Registry import failed with status code $($process.ExitCode)"
} 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 this Stack Overflow example.
Conclusion
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.
Summary
- You can use the regedit command with the /s parameter to import a .reg file silently into the Windows Registry.
- PowerShell cmdlets like New-Item and New-ItemProperty can create registry keys quietly by piping output to Out-Null.
- When using PowerShell, remember to quote and escape any spaces in your ArgumentList arguments.
- The methods shown allow you to silently import .reg files across various Windows versions, including Windows 10 and 11.