Search code examples
pythonwindowswxpythonpy2exe

how to start a batch file that runs after my application closes


I have written a windows gui application using wxPython that is compiled into an executable using py2exe. I'm trying to make the program check for a new version on our website, download it, and then overwrite itself. So far the entire feature is working except that it unsurprisingly can't overwrite a running application (it successfully overwrites all of the supporting files, however). The solution I've devised is that I have it copy the new application executable under a temporary filename and I've written a batch file that will continuously attempt to overwrite the existing file until it succeeds. I've tested this and it also works if I run the batch file independently (i.e. manually). Now my problem, and my question, is: how can I have my application kick off the batch file but not wait for it to finish before exiting so that the batch file can then complete the copy operation?

I've tried the following and they all cause the application to hang:

os.spawnl(os.P_NOWAIT, 'mybatfile.bat')
os.spawnl(os.P_DETACH, 'mybatfile.bat')
os.execl('mybatfile.bat')

Solution

  • wxPython comes with Esky support built-in. Why not use just that? It is a library for updating frozen applications: