Powershell Script to Auto Import .REG files in Current Directory

A simple PowerShell script which will auto import .REG files in the current directory. Useful for automating deployments or machine setup.

By Tim Trott | Windows Tips and Tricks | October 6, 2017

I frequently need to import a bunch of Registry settings stored in an individual .REG files. These are for common machine setup tasks like adding scheduler entries, setting some default Windows settings, adding missing screen resolutions to Surface Book, removing library folders from Explorer and so on.

I could merge all of them into a single .REG file, but that introduces other problems including maintainability.

Instead, I use a Powershell script which will iterate over all the .REG files in the current directory and import each one it finds.

powershell
#Grab current directory
$oInvocation = (Get-Variable MyInvocation).Value
$sCurrentDirectory = Split-Path $oInvocation.MyCommand.Path

#Grab all .reg and pipe it into a reg import command
Get-ChildItem $sCurrentDirectory -Filter "install.exe" -Recurse | 
foreach{
 Start-Process -FilePath "C:\windows\system32\cmd.exe" -WindowStyle Minimized `
 -ArgumentList @('/C REG IMPORT "' + $_.FullName + '"') -Wait
}
Was this article helpful to you?
 

Related ArticlesThese articles may also be of interest to you

CommentsShare your thoughts in the comments below

If you enjoyed reading this article, or it helped you in some way, all I ask in return is you leave a comment below or share this page with your friends. Thank you.

There are no comments yet. Why not get the discussion started?

We respect your privacy, and will not make your email public. Learn how your comment data is processed.