Search code examples
javapythonwindowscmdexe

How to make an executable File


Everybody probably has used install .exe files. But how to make them and when does it make sense to make one?

For example, I would have had programmed commercial software in Python, c++, etc. with different files a GUI and pictures and all of the other stuff.

When I want to deliver my product to my customer I don't want to give them a folder and say you need to install Python or Java and execute the program via your command line.

How can I create an executable file that installs the required language and sets up local instances and arranges all files into the correct order?


Solution

  • To create an executable file from a python program, there is pyinstaller. I don't know about java at the moment. The command is as follows :

    pyinstaller fileName.py
    

    You can add args (and there are 2 really helpful ones) :

    pyinstaller --onefile -w fileName.py
    

    --onefile will put everything into one single file (recommended) and -w will prevent the console from opening when running the .exe file. Add it if you're running a GUI or something. If you need to console for input, don't add -w.

    If you want to automate a command line in cmd, create a shortcut leading to C:\Windows\system32\cmd.exe and add /k and your command. For example :

    C:\Windows\system32\cmd.exe /k ipconfig
    

    Double clicking on the shortcut will now run the cmd and execute ipconfig automatically. If you want more than one command, you can do command_1 && command_2 && ... && command_n