For anyone else that stumbles across this question, iI managed to solve the issue using a batch file with the following code:
cd C:\Program Files\QGIS 3.4\bin
qgis --project "path to .qgz project file" --code "path to .py python code file"
The gqisqgis
bit in the second line needs to match whatever .bat file is run to open QGIS. forFor some users this was qgis-ltr. This launches qgisQGIS and opens a saved project, then runs the python script.
And my python script needed to start with the following to execute properly:
from qgis.core import *
import qgis.utils
from qgis.utils import iface