See also:
http://hub.qgis.org/issues/12623

Maybe it is a bit tricky for a general solution, since variables are defined 
and named differently on the different OSes?...

As a workaround you could probably put a string replacement procedure into your 
QGIS.bat?
We used e.g. a "#USERPROFILE#" string, as a placeholder, which got replaced 
when a custom QGIS2 folder template - containing the QGIS.ini - was copied to a 
new user...

Not too trivial to replace a string in a text-file on Windows using batch (I 
understood from my colleagues)...

Cheers
Stefan

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Bo Victor Thomsen
Sent: 22. juni 2015 11:32
To: [email protected]
Subject: [Qgis-developer] Using environment variables in path definitions in 
QGIS

To the QGIS developers list -

I have a goal of making a fully portable Windows edition of QGIS. "Fully 
portable" means that I simply can install QGIS by copying the QGIS program 
directory to a location on the users PC and  start QGIS by double clicking on 
the QGIS.bat file in the "..\bin" directory.

I've reached 95% of my target by using the OSGeo4W installation as a template 
and making some modification the the start-up bat file. Mostly by using the 
--configpath qualifier to 1) redefine the location of the QGIS user directory 
.qgis2 and 2) not using the registry to save option values.

By using the --configpath qualifier QGIS creates and uses the 
.qgis2\QGIS\QGIS2.ini file to store option values normally located in the 
registry. Some of these values are path definitions:

example:

Configuration\SAGA_FOLDER=C:/OSGeo4W/apps\\saga
Configuration\GRASS_WIN_SHELL=C:/OSGeo4W/apps\\msys
Configuration\R_SCRIPTS_FOLDER=C:\\OSGeo4W\\.qgis2\\processing\\rscripts

I would like to use environment variables as part of the path definition in the 
ini file like this:

Configuration\SAGA_FOLDER=%OSGEO4W_HOME%/apps\\saga
Configuration\GRASS_WIN_SHELL=%OSGEO4W_HOME%/apps\\msys
Configuration\R_SCRIPTS_FOLDER=%QGIS_USERDIR%\\processing\\rscripts

(OSGEO4W_HOME and QGIS_USERDIR is environment variables, that contains the path 
for the QGIS program directory and the QGIS user directory)

The problem is, that QGIS doesn't interpret the %......% as a environment 
variable and replace it with the value of the variable but simply interprets it 
literally resulting in paths containing "%" - signs and environment variable 
names.

Is there a method to get QGIS to interpret the environment variable and replace 
it with the content of the variable ? Or should a put it on the wish list in 
the bug tracker ?

Regards
Bo Victor Thomsen
AestasGIS
Denmark



_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to