Tell me please, how can I get current version of installed QGIS from command line (batch-file). QGIS installed with Osgeo4w-installer.
Registry search did not return any result.
Tell me please, how can I get current version of installed QGIS from command line (batch-file). QGIS installed with Osgeo4w-installer.
Registry search did not return any result.
To report here the answer of Zoltan in the comment: running
qgis-ltr-bin --version
or qgis-bin --version
should print the version number (since 3.8). It can be run via the OSGeo Shell or in a normal shell window (just provide the full path like C:\OSGeo4W\bin\qgis-ltr-bin.exe --version
).
However on Windows, nothing will be printed on the console if you use the old command line cmd.exe (see this ticket to know more). If you use it, you need to pipe the (hidden) output with qgis-ltr-bin --version > version.txt
to get a file named version.txt
containing a string similar to QGIS 3.16.9-Hannover 'Hannover' (9f8d2f79)
.
If instead one use the Windows Powershell, qgis-ltr-bin --version | echo
will print to the console (hat tip to @nlaan).
For reference, below are all the available commands for qgis-ltr-bin
/qgis-bin
:
qgis-ltr-bin.exe --version | echo
Unfortunately I am not good enough with Windows batch files or Power shell scripts but I can show where the OSGeo4W installer is storing that info. It can be found from the temp directory that is used for caching the downloaded packages before installation. The location is by default something like
C:\Users\SOME_USER\AppData\Local\Temp\http%3a%2f%2fdownload.osgeo.org%2fosgeo4w%2f\x86_64>
The http
part in the path name is the URL of the mirror that was used when the installer was run. The file to look at is setup.ini
and it contains a section for each installed item.
@ qgis
sdesc: "QGIS Desktop"
ldesc: "QGIS Desktop"
category: Desktop
requires: qgis-common python3-core pyqt5 python3-gdal gpsbabel python3-psycopg2 python3-qscintilla python3-jinja2 python3-markupsafe python3-pygments python3-python-dateutil python3-pytz python3-future python3-requests python3-pyproj python3-pyyaml python3-plotly python3-owslib python3-httplib2 python3-nose2 python3-mock qt5-qml exiv2 qt5-tools
version: 3.14.16-2
install: x86_64/release/qgis/qgis/qgis-3.14.16-2.tar.bz2 49937472 b203a2993cff9783d3bb9565126a0700
[prev]
version: 3.14.16-1
install: x86_64/release/qgis/qgis/qgis-3.14.16-1.tar.bz2 49942698 14ef4259f23d1b67be8f82189d7e0b70
The challenge for the script-writers is simply "Find string @ GIS
. It must be exact match to avoid lines like @ qgis-dev
. Probably there are no white spaces on the line but I am not sure. Alternatively find sdesc: "QGIS Desktop"
). The version is on the 6th line of the block.
I would love to see this solved with awk but unfortunately it does not come with Windows.
@echo off call "%~dp0\o4w_env.bat" call qt5_env.bat call py3_env.bat @echo off path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH% set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis set GDAL_FILENAME_IS_UTF8=YES rem Set VSI cache to be used as buffer, see #6448 set VSI_CACHE=TRUE set VSI_CACHE_SIZE=1000000 set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins start "QGIS" /B "%OSGEO4W_ROOT%\bin\qgis-bin.exe" %*
Commented
Oct 28, 2020 at 15:38
qgis.req
. There is a key [HKEY_CLASSES_ROOT\QGIS Project\Shell\open\command] @="\"C:\\OSGEO4~1\\bin\\qgis.bat\" \"%1\""
. So QGIS project is opened with qgis.bat that starts the binary that has a fixed name and location start "QGIS" /B "%OSGEO4W_ROOT%\bin\qgis-bin.exe" %*
. And registry is edited with some post-install batch file magic. See qgis.bat.done that you have in OSGeo4W64\etc\postinstall. Keys seem to be for the ROOT user.
Commented
Oct 28, 2020 at 17:24