[Qgis-user] Selecting profiles

Charles Dixon-Paver charles at kartoza.com
Thu Mar 18 10:13:09 PDT 2021


OK... I'll do my best to assist assuming all dispatchers are using Windows
and QGIS is installed using the OSGeo4W with default settings.

Assuming you had dispatchers named "foo" and "bar", and you had user
profiles called "foo" and "bar", you could a text file called
"qgis-foo.cmd" and put the following content in it to fire up QGIS as the
user "foo":

----------
@echo off
@setlocal enableextensions
@cd /d "%~dp0"

Set "MYPROFILE=foo"

%COMSPEC% /C "CALL C:\OSGeo4W64\bin\qgis.bat --profile %MYPROFILE% %*"
----------

Then you can do the same for "qgis-bar.cmd" and change the file to say Set
"MYPROFILE=bar"

If you wanted to call a particular project, you could use
"myproject-foo.cmd" and add another parameter like so:

----------
@echo off
@setlocal enableextensions
@cd /d "%~dp0"

Set "MYPROFILE=foo"

%COMSPEC% /C "CALL C:\OSGeo4W64\bin\qgis.bat --profile %MYPROFILE%
--project C:\projects\myproject.qgz %*"
----------

If at all possible I would avoid any spaces in the path to your project, or
put your cmd file in the same folder as the project and replace
C:\projects\myproject.qgz with %~dp0\myproject.qgz (%~dp0 just means "path
to the cmd file")

If, on the other hand, foo and bar log into windows as separate users, you
could simply copy the relevant profile from your appdata directory and
place it in their user directory, renaming it to the relevant generic
profile name. So, for example, you could copy the directory
"C:\Users\MisterAdministrator\AppData\Roaming\QGIS\QGIS3\profiles\foo" to
"C:\Users\foo\AppData\Roaming\QGIS\QGIS3\profiles\911"

Then you could just give each user a link to "qgis.cmd" which has the
following inside:

----------
@echo off
@setlocal enableextensions
@cd /d "%~dp0"

Set "MYPROFILE=911"

%COMSPEC% /C "CALL C:\OSGeo4W64\bin\qgis.bat --profile %MYPROFILE% %*"
----------

You could also set the system or user PATH variable to point to "qgis.cmd",
so all "qgs" and "qgz" files are opened with that launcher by default, but
that's a bit out of scope for the current conversation.

I hope that helps and is not too confusing.

On Thu, 18 Mar 2021 at 18:39, Ed Hawkins <elh1964 at gmail.com> wrote:

> Thanks for the reply Charles,  I will see if I can try this.  I have VERY
> little programming experience, and haven't done much with batch files since
> the days of DOS.  I work at a Emergency 911 and want to give our
> dispatchers a customized version of QGIS without the editing capability,
> but there are 3 of us that go and collect addresses and I want to set some
> variables that will populate certain fields based on who is collecting or
> editing data(I have figured this part out already) but knowing some of the
> other collectors they may think it is too much trouble to select a profile
> which is why I would like them to be forced to select their profile.  I
> would have figured this would have already been tried by someone else but I
> can't find anyone who has done it.
> Thanks again,
> Ed
>
>
> *Edwin L. Hawkins Jr.,**AASGIS, GISP*
>
> Henderson County TN E911
>
> GIS Administrator
>
> Cell 731.358.7932
>
>
>
>
>
>
> On Thu, Mar 18, 2021 at 4:24 AM Charles Dixon-Paver <charles at kartoza.com>
> wrote:
>
>> Creating a custom shortcut/ launcher is also the only way I can think of.
>> There was a related thread on this previously in which various possible
>> solutions using python, bash scripts or windows batchfiles were provided,
>> which may be useful for your needs.
>>
>>
>> http://osgeo-org.1560.x6.nabble.com/Have-QGIS-prompt-for-profile-to-use-everytime-td5448226.html
>>
>> User profiles are usually stored in the user/ appdata directory on the OS
>> though, so you can also manage access permissions/ profiles through that
>> depending on your environment setup.
>>
>> On Thu, 18 Mar 2021 at 03:40, Alexandre Neto <senhor.neto at gmail.com>
>> wrote:
>>
>>> Hi Ed,
>>>
>>> The only way I think of is by creating a shortcut that launches QGIS
>>> using the command line tools. Using this, you can specify which profile to
>>> use and which project:
>>>
>>>
>>> https://docs.qgis.org/3.16/en/docs/user_manual/introduction/qgis_configuration.html#command-line-and-environment-variables
>>>
>>> Best regards,
>>>
>>> Alexandre Neto
>>> QGIS Support
>>> www.cooperative.net
>>>
>>> On Wed, Mar 17, 2021 at 10:44 PM Ed Hawkins <elh1964 at gmail.com> wrote:
>>>
>>>> I have created 4 profiles a reader qith no editing capabilities and 3
>>>> editors. I want to force someone opening a project to select a
>>>> user profile. Is that possible and if so how?
>>>> Ed Hawkins
>>>> Henderso County E911
>>>>
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at lists.osgeo.org
>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210318/57d3f714/attachment.html>


More information about the Qgis-user mailing list