I have a batch file which calls another batch file used for GIS software. I can run this and also input a command to run python
, but how I can run more commands without having the user to input them? The following is the script which works:
@echo off
rem Root OSGEO4W home dir to the following directory
call "C:\OSGeo4W64\bin\o4w_env.bat"
rem List available o4w programs
rem but only if osgeo4w called without parameters
@echo on
set PYTHONPATH=C:\OSGeo4W64\apps\qgis\python
set PATH=C:\OSGeo4W64\apps\qgis\bin;%PATH%
@echo off
echo.
cmd /k python
@echo on
And I would like to run the following commands automatically:
import qgis.core
import qgis.gui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
Any help is greatly appreciated as I am a beginner.
You can use redirection of the python script
text
(
echo import qgis.core
echo import qgis.gui
echo from PyQt4.QtCore import *
echo from PyQt4.QtGui import *
) | python
Or you put your python code into a second file and start that external python script from your batch file with something like.
python myScript.py
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.