1

I am trying to add one executable (.exe) file, a .conf file and a .bat file into the binary package created by pyinstaller and then through that binary package i want to call the .bat file that will send some commands to .exe and that exe will pick the configuration file from .conf and do its work.

** Example **

  1. Click on Run button from Python Package.

  2. Python Package runs .bat file inside it.

  3. .bat file calls .exe with arguments

  4. .exe picks config from .conf file and do its work

4
  • What is the error? Where you are stuck? What have you tried till now?
    – PySaad
    Jul 20, 2019 at 8:12
  • @py_saad i have no idea how to run that .bat file and how it will run the .exe Jul 20, 2019 at 8:16
  • All the instructions are written in .bat and you run it by double click it. At the end of .bat file, add pause to check if there is any error while execution. If you don't add pause, console will appear and it will disappear instantly
    – PySaad
    Jul 20, 2019 at 8:21
  • @py_saad you didnt get me, i am adding those files to python package made using pyinstaller by --add-data attribute. How to run that .bat file inside python .exe package Jul 20, 2019 at 8:23

1 Answer 1

2

Before you create the binary through pyinstaller:

  1. Add files (.conf and .bat and .exe) to the bundle using the Analysis call in the .spec file. When you run the binary created through pyinstaller it unpacks itself at a temporary location in AppData on Windows by default. You should be able to get that path through sys._MEIPASS
  2. In the python script run the .conf, .bat and .exe files preferably using subprocess.
1
  • 1
    Thank You, I already found this answer and it is the same as yours one :) Jul 20, 2019 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.