title: How to call a process from an .exe file
body: <p>I have a program called <code>test.exe</code>. The program was written in python/pyqt4. At some point along the code I want to trigger a restart of the application so I need to create a detached process which runs independent from the main process in order to fire the program and close the currently running one immediately after.</p>
  
  <p>The problem is that it doesnt want to work no matter how I try. Instead of executing the same exe I also tried creating a .bat file which then calls the exe after a timeout (I added a ping to localhost).</p>
  
  <p>If I try to execute some other program like a copy of notepad.exe it works with no issues but I can't get to a solution in order to restart an application. Here's my test code:</p>
  
  <pre><code>import os
  import sys
  import subprocess
  
  from PyQt4 import QtGui, QtCore
  
  if getattr( sys, 'frozen', False ):
      ROOT_PATH = os.path.dirname( os.path.abspath( sys.executable ) )
  elif __file__:
      ROOT_PATH = os.path.dirname( os.path.abspath( __file__ ) )
  
  
  class Example( QtGui.QWidget ):
  
      def __init__(self):
          super(Example, self).__init__()
          self.initUI()
  
      def initUI( self ):
          qbtn = QtGui.QPushButton('Quit', self)
          qbtn.clicked.connect( self.btn_clicked )
          qbtn.resize(qbtn.sizeHint())
          qbtn.move(50, 50)       
  
          self.setGeometry(300, 300, 250, 150)
          self.setWindowTitle('Quit button')    
          self.show()
  
      def btn_clicked( self ):
          p = QtCore.QProcess()
          p.setWorkingDirectory( ROOT_PATH )
          p.startDetached( "start.bat" )
          sys.exit( 0 )
  
  def main():
      app = QtGui.QApplication(sys.argv)
      ex = Example()
      sys.exit(app.exec_())
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>The <code>exe</code> is compiled using pyinstaller and in my final location I have <code>text.exe</code> and <code>start.bat</code> which looks like this:</p>
  
  <pre><code>ping 127.0.0.1 &gt; "bat.txt"
  start "" "%~dp0test.exe"
  </code></pre>
  
  <p>If I replace <code>test.exe</code> with <code>notepad.exe</code> in my bat file it works.
  Any ideas? </p>