How to run the .reg file using PowerShell? How to run the .reg file using PowerShell? powershell powershell

How to run the .reg file using PowerShell?


How about using reg.exe instead of regedit.exe

Get-Command regCommandType     Name                                               Version    Source-----------     ----                                               -------    ------Application     reg.exe                                            10.0.16... C:\Windows\system32\reg.exe

this worked for me fine:

reg import .\test.reg


I use

Invoke-Command {reg import \\server\share\test.reg *>&1 | Out-Null}

the last part

*>&1 | Out-Null

pipes the output to null so the console doesn't see it. I do not think this is required but it annoyed me.


You may be trying to run it with insufficient privileges. This snippet should work:

$startprocessParams = @{    FilePath     = "$Env:SystemRoot\REGEDIT.exe"    ArgumentList = '/s', 'C:\file.reg'    Verb         = 'RunAs'    PassThru     = $true    Wait         = $true}$proc = Start-Process @startprocessParamsif ($proc.ExitCode -eq 0) {    'Success!'}else {    "Fail! Exit code: $($Proc.ExitCode)"}Pause