I have a question please - I have a .reg file I want to merge after an installer - so I have added the below command to run below the installer. But it doesn’t add the .reg file to the device’s registry.
Could someone advise if I am doing something wrong with the command I am using?
Execute-Process -FilePath “reg.exe” -Parameters “import $dirSupportFiles\MBS_FLRegkey_Licence.reg” -PassThru
The whole installation is going to be running under system context.
TIA for any help / advise.
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
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