Merge - Reg Key after install

You could try this:

$Results = Execute-Process -FilePath "reg.exe" -Parameters "import `"$dirSupportFiles\MBS_FLRegkey_Licence.reg`" " -PassThru

The way you wrote the command will only work if $dirSupportFiles does not contain spaces. I added escaped double quotes for that path.

-Passthru will return the Exitcode, STDOUT, and STDERR in an array. You didn’t have an array so I added $Results
I think the Exitcode, STDOUT, and STDERR will got to the PSADT log file regardless.

Also the REG file will work as expected if all the lines are for HKLM hive.
If you have HKCU lines in the REG file, then I think the Default User hive gets the changes when you run as SYSTEM, not the current user.

You could also use this add-on function for REG files

I also have my own Import-RegFile function

1 Like