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 TrottWindows Tips and Tricks • October 6, 2017

I frequently need to import many 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 that will iterate everything.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
}

Related ArticlesThese articles may also be of interest to you

CommentsShare your thoughts in the comments below

My website and its content are free to use without the clutter of adverts, popups, marketing messages or anything else like that. 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?

New comments for this post are currently closed.