<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi Thomas -</p>
    <p>Your suggestion is actually pretty close to the solution I made -</p>
    <ul>
      <li>Standard installation of QGIS with <i>standard</i> .msi
        package.<br>
      </li>
      <li>After the QGIS installation and before QGIS is started the
        user do a one-time run a Python script from et central network
        drive -  using the Python interpreter installed together with
        QGIS  which:<br>
      </li>
      <ul>
        <li>Unzip a complete profile  with specific plugins and
          customized parameters from a central network based repository.
          This profile replaces the standard "default" profile.<br>
        </li>
        <li>Search/replace a couple of "tokenized" values in QGIS.ini
          with actual values based on username   <br>
        </li>
      </ul>
    </ul>
    <p>The profile and tokenized QGIS.ini is prepared by the GIS
      administrator</p>
    <p>The Python script is packaged in a .cmd file which is started by
      the user.</p>
    <p>Not a perfect solution, but doable: <br>
    </p>
    <ul>
      <li>The It department is happy: No work doing specialized
        installations</li>
      <li>The GIS administrator is happy. It's a one-time piece of work
        for each QGIS version to  prepare the profile and tokenize the
        QGIS.ini <br>
      </li>
      <li>The user is - somewhat - happy. To finish the installation is
        simply to double-click once on a file placed in a "highly
        visible" location.</li>
      <li>Any subsequent mistakes made by the user (Installation of
        dodgy plugins, strange changes in setups ....) is easily
        repaired by running the Python script again.<br>
      </li>
    </ul>
    <p> <br>
    </p>
    <pre class="moz-signature" cols="72">Med venlig hilsen / Kind regards

Bo Victor Thomsen</pre>
    <div class="moz-cite-prefix">Den 12-07-2021 kl. 03:14 skrev Thomas
      Gratier:<br>
    </div>
    <blockquote type="cite"
cite="mid:CACPZzQ0TKRHHtcmnBzCWFNQ0D=QUZwPGjGRHAPeaTFvNXQK5wA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi,<br>
        <br>
        I'm not aware QSettings provided by Qt can do it. Your %APPDATA%
        is not portable as would only work on Windows<br>
        <br>
        You can always try generate the QGIS.ini file using a templating
        system<br>
        <br>
        File QGIS.ini.j2 with following content<br>
        <br>
Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models<br>
Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts<br>
        <br>
        <br>
        File generate_ini.py with following content<br>
        <br>
        import os<br>
        import jinja2<br>
        <br>
        templateLoader = jinja2.FileSystemLoader(searchpath="./")<br>
        templateEnv = jinja2.Environment(loader=templateLoader)<br>
        TEMPLATE_FILE = "QGIS.ini.j2"<br>
        template = templateEnv.get_template(TEMPLATE_FILE)<br>
        mydict = {<br>
            "APPDATA": os.environ.get("APPDATA")<br>
        }<br>
        outputText = template.render(**mydict)<br>
        with open('QGIS.ini', 'w') as outputfile:<br>
            outputfile.write(outputText)<br>
        <br>
        Then, to write your QGIS.ini file, do<br>
        <br>
        <br>
        python3 generate_ini.py<br>
        <br>
        <br>
        The possible deal breakers with this approach are:<br>
        - you depend from jinja2, a third party Python library,<br>
        - you can't later reuse the mechanism if for instance QGIS
        changes the QGIS.ini file later on<br>
        <br>
        <br>
        Regards<br>
        <br>
        Thomas<br>
        <br>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">Le mar. 6 juil. 2021 à 09:18,
          Bo Victor Thomsen <<a
            href="mailto:bo.victor.thomsen@gmail.com"
            moz-do-not-send="true">bo.victor.thomsen@gmail.com</a>> a
          écrit :<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p>To the list -</p>
            <p>Is there a method to use OS (Linux, Windows...)
              environment variables in the QGIS.ini setup file ?</p>
            <p>I had a number of customers asking for a method to
              "generalize" QGIS.ini, so it doesn't contain any "user"
              specific file and directory references, i.e</p>
            <p>(From qgis.ini) <br>
            </p>
            <p><font face="monospace">Configuration\MODELS_FOLDER=<b>C:\\Users\\Bo
                  Victor Thomsen\\AppData\\Roaming</b>\\QGIS\\QGIS3\\profiles\\default\\processing\\models<br>
                Configuration\SCRIPTS_FOLDERS=<b>C:\\Users\\Bo Victor
                  Thomsen\\AppData\\Roaming</b>\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts<br>
              </font></p>
            <p>could be: <br>
            </p>
            <p><font face="monospace">Configuration\MODELS_FOLDER=<b>%APPDATA%</b>\\QGIS\\QGIS3\\profiles\\default\\processing\\models<br>
                Configuration\SCRIPTS_FOLDERS=<b>%APPDATA%</b>\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts</font><br>
            </p>
            <p>or likewise.</p>
            <p>The ultimate reason is to have a method to distribute a
              "standard" setup for QGIS, complete with plugins and
              specialized setup parameters. This can be done by making a
              standard QGIS installation (which the IT departments love,
              especially with the new .msi package) and afterwards
              replace the "default" profile directory with at  directory
              specific for the organisation. However, the process of
              making the new profile will place a lot of file/directory
              references in QGIS.ini that is specific for the super-user
              developing the new profile.<br>
            </p>
            <pre cols="72">-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen</pre>
          </div>
          _______________________________________________<br>
          QGIS-Developer mailing list<br>
          <a href="mailto:QGIS-Developer@lists.osgeo.org"
            target="_blank" moz-do-not-send="true">QGIS-Developer@lists.osgeo.org</a><br>
          List info: <a
            href="https://lists.osgeo.org/mailman/listinfo/qgis-developer"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
          Unsubscribe: <a
            href="https://lists.osgeo.org/mailman/listinfo/qgis-developer"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
        </blockquote>
      </div>
    </blockquote>
  </body>
</html>