Powershell Post to Auto-Import all .REG files from Current Directory (Script Directory)

By | May 30, 2013
Share

Here is a script/package that I like to include when consulting. It simply auto-imports all .reg files from the same directory where the script is stored. Its great, because people can simply export .reg files and add them into the folder and the next time a deployment takes place, the .reg file is imported.

#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
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.