Adding registry key during deployment is not working

As part of deployment we need to add or update windows registry. I have a .reg file which is part of the project and was deployed along with it by tfs build. I have also added a script step to run this file during deployment using the following command:

regedit /s PollerRegistry.reg

Now, Octopus doesn’t show any error and reports it has run the script successfully but I don’t see the registry key if I open the registry editor.

What could be wrong?


regedit is pretty unhelpful when it comes with reporting errors and exit codes, so could I get you to try and use reg import PollerRegistry.reg instead and see if that gives any more information as to why it isn’t working?

Thank you and best regards,

Hi Henrik,

Thank you very much for the quick reply. Yes, your suggestion did shed some light on why it didn’t work.

Primarily there was a file IO error because “regedit” was looking for the PollerRegistry.reg file in the Octopus work folder and it wasn’t there. So I had to get the installation folder from the previous step like below and use that .

$InstallationDirectory  = $OctopusParameters["Octopus.Action[Deploy Service].Output.Package.InstallationDirectoryPath"]
    $RegistryFilePath  = "$($InstallationDirectory)$('\PollerRegistry.reg')"
    Write-Host "$('Running script from:') - $($RegistryFilePath)"
    reg import $RegistryFilePath

Once again, thank you for your quick help.


Great to hear you got it working!

Thank you and best regards,