I have a Python Program for doing some geoprocessing in QGIS. The starting of the Python program is given below. import sys from qgis.core import * import qgis.utils from qgis.gui import * from PyQt4.QtGui import * from PyQt4.QtCore import Qt from qgis.core import QgsApplication from PyQt4.QtGui import QApplication QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis", True) QgsApplication.initQgis() sys.path.append('C:/OSGeo4W/apps/qgis/plugins') from processing.core.Processing import Processing Processing.initialize() from processing.tools import * from PyQt4.QtCore import QFileInfo import processing import os import ogr from osgeo import ogr, gdal import math import xlrd ..............................many other lines................. I want to execute this python program from a Windows Batch File, that is .bat file; even without opening QGIS software. For that, I created a .bat file as given below. SET QGIS_PREFIX_PATH=C:\OSGeo4W\apps\qgis call "C:/OSGeo4W/bin/o4w_env.bat" SET PYTHONPATH=C:\OSGeo4W\apps\qgis\python;%PYTHONPATH% SET PATH=%PATH%;C:\OSGeo4W\apps\qgis\bin cmd /c python "C:/Users/Sreeraj/.qgis2/processing/scripts/Task3.py" Unfortunately, when I am executing this .bat file, in C:\WINDOWS\system32\cmd.exe , I am getting an error: python.exe has stopped working A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available. How can I solve this issue ? I doubt that the issue is in the given below lines of my python program (I am not sure about this; just a doubt on these lines). from qgis.core import QgsApplication from PyQt4.QtGui import QApplication QgsApplication.setPrefixPath("C:/OSGeo4W/apps/qgis", True) QgsApplication.initQgis() sys.path.append('C:/OSGeo4W/apps/qgis/plugins') Or is this error occuring because of some other lines in my python program ? I don't know exactly. What modification do I have to make in .bat file or in my Python program, in order to solve this issue ?