Search code examples
installationregistryinno-setuppascalscript

Import .reg registry files silently in Inno Setup


I have a need to run few registry files via Inno Setup within the code. I can not use [Registry] section as this is a standard installation kit which should pick .reg files created and run them.

Exec('regedit.exe', 'C:\Support\MyReg.reg', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)

I want to run this silently so I tried the following.

Exec('regedit.exe', 'C:\Support\MyReg.reg /s', '', SW_HIDE, ewWaitUntilTerminated, ResultCode)

But it does not work. Can anybody tell me what I am missing here?


Solution

  • The /s has to come before the path:

    Exec('regedit.exe', '/s C:\Support\MyReg.reg', '', SW_HIDE, ewWaitUntilTerminated, Code);
    

    Though I suggest you better use the command-line registry tool, the reg.exe:

    Exec('reg.exe', 'import C:\Support\Banners.reg', '', SW_HIDE, ewWaitUntilTerminated, Code);