Search code examples
xamppregistryinno-setupwar

Inno Setup ReadReg run-time target program folder, add WAR file to tomcat/webapps


I would like to save a WAR file to xampp\tomcat\webapps by using Inno Setup's ReadReg functionality to find the Install_Dir for XAMPP. This question is similar to Inno Setup: read source path from a registry on compile time but I think the answer I need is flip-flopped. Here's what I have:

Source: "D:\Content.war"; \
  DestDir: "{#ReadReg(HKLM, "SOFTWARE\xampp", "Install_Dir", "DefaultDirName")}\tomcat\webapps"; \
  Flags: ignoreversion

But it doesn't save the WAR file to the target computer's XAMPP folder. Please let me know how this should be properly structured/coded.


Solution

  • Use a scripted constant and RegQueryStringValue function:

    [Files]
    Source: "D:\Content.war"; DestDir: "{code:GetXamppPath}\tomcat\webapps"
    
    [Code]
    
    function GetXamppPath(Param: string): string;
    begin
      RegQueryStringValue(HKLM, 'SOFTWARE\xampp', 'Install_Dir', Result);
    end;
    

    Though you should also add some error handling (particularly in case there's no such registry key).


    Btw, the answer that you have based your script on is correct. But it does, what the other question asks for: it reads the key on compile-time = on the machine, where it is built on. That's not what you want.