Is it possible to check whether QGIS3 was started by executing qgis.bat or qgis.exe directly?
I want to do some checks in the qgis.bat before qgis starts and make sure that qgis is always started by calling the qgis.bat.
Edit1:
One idea is to set an environment variable in the qgis bat and check in the startup.py if this environmental variable is found:
bat-file:
set batchfilestart="YES"
python part
import os
try:
env_value = os.environ.get("batchfilestart")
if env_value !="YES":
print ("QGIS not started by calling the bat file")
print (env_value)
else:
print("QGIS started by calling the bat file")
print (env_value)
except KeyError:
print("Not exist environment value for %s" % "key_maybe_not_exist")
Is there a better way to make sure I can always run some checks before QGIS starts?
pause
into qgis.bat? Then if you will see a messagePress any key to continue . . .
if you have launched the .bat file. Or rename qgis-bin.exe into foo.exe and edit the qgis.bat accordingly. At least for me foo.exe does not start at all but edited qgis.bat works. I was testing with the QSGeo4W installation.Oops, looks like an error loading QGIS
follows.