No announcement yet.

Text file advice

  • Filter
  • Time
  • Show
Clear All
new posts

  • Text file advice

    I am looking for advice on how to edit a file. The file type is a .arg. It's essentially just a text file. The file will be included in the installer. Is it possible to edit part of the text in this file? I can see reference to TextFile.WriteFromString but I don't know how to implement this.

    Thanks in advance.

  • #2
    You certainly should be able to edit the file, what have you tried?



    • #3
      Hi Ulrich,
      That is sort my point. I don't know where to start. I used to use a custom .exe file but this is not a good way as it's out of the software. I want to see if there is a way inside MSI Factory. I don't know where to start.


      • #4
        Okay, You probably want to run a custom action, which executes a simple Lua script, to edit the file. Is this file already on the user's system, or will it be deployed as part of the MSI? Can you provide a sample *.arg file, and a detailed description what would need to be changed in the file? I could try building a demo project.



        • #5
          Oh thank you that's relly great.
          The text in the file I want to change is this string: "$$$-PLACEHOLDER1-$$$" (Although it could be anything)

          And I want to change it to the value of registry value, the install location of my programe.

          The file attached will be in cluded in the installer.

          Hope that is enough info, if not please let me know.
          Attached Files


          • #6
            Okay, here is a sample. You will see a custom action, to run a Lua script. This action will be executed after InstallFinalize, so after the files were deployed. The script itself should be easy enough to understand, but there are two things you should notice:

            1. If the intention is writing values and keys to the registry, please use the functions for this available in Windows Installer. You should use custom actions like in this samples only for stuff which cannot be easily done the "correct way".

            2. In this sample, I am deploying the *.arg file into the application folder, normally under ProgramFiles. This is a problem is that the logged user does not have access rights to write files here, and administrator rights are required. The custom action will not use the admin privileges granted by the User Account Control dialog, but the logged user's privileges instead. (You can run Lua script with admin rights, but this would require to run it in deferred mode, which does not grant access to the properties we need here.) So clearly, the proper location to deploy this file would be somewhere where the logged user has write access to, for example the TEMP folder, the AppData folder, etc. - you get the idea. So, in order to allow that the script triggered by the custom action can write the updated content, I changed the permissions on this file as a workaround.

            3. The custom action will only run during installation, not during the removal. This is controlled by the "NOT Installed" condition.

            Just decompress the attached zip, and try to build the MSI, withou any modifications. Once you see how it works, you should be able to make the desired changes to your own project.

            Attached Files


            • #7
              Thank you Ulrich,
              I will dig through it and have a look.