How to change a file inside a .exe in python? - python

I've made a nsis installer for my application and want to change one of the files inside the installer .exe. Is there a way to open the installer and change one of the files inside, similar to ZipFile?
The reason for doing this is I want to add a unique token so I can later identify which user has downloaded the app. Generating a new installer from scratch with the token inside would be too slow.

No, you cannot change files inside the installer.
What you can do however is to append some text to the end of the exe on the server and then read it in the installer.
If you have a lot of data, you can append it in a .cab file and use the CabX plug-in (CabX::FromSelf).

Related

How to update an py made exe file from my pc to people I have sent it to?

What I mean is that I have a py file which I have converted to an exe file. So I wanted to know in case I decide to update the py file then how do I make it if I have sent it to someone the same changes occur in his file as well whether the exe or py file.
Just send them the new exe file. But if you expect updates to be performed regularly consider adding the auto-update logic to your program using the PyUpdater library
Auto updating a python executable generated with pyinstaller
Put your version of the program on a file share, or make it otherwise available in the internet and build in an update check in the program. So that it checks the URL for a new version everytime it is started.
I guess this is the most common way to do something like that.

How to remove hard coded file paths from python script for creating executable installer?

So I created a fairly intricate python script with a tkinter GUI that creates many user-defined text files and uses them to create and run a batch script as a sub-process which in turn creates multiple XML files that I parse for data and write to a final, single excel file using xlsxwriter.
Bottom line is this script works flawlessly on my personal machine and has file paths hard-coded into it all centered around a root folder on my desktop. For the sake of my machine, this script is great and does what it needs to do. Now, I want to get this distributed to other computers using an installer that removes necessity to have all external dependencies. I see that py2exe is a useful tool for incorporating these modules (like xlsxwriter) but I'm not sure about how to go about creating an installer that gets rid of hard coded file paths.
Essentially, I want to create something that asks the user to select where a certain program is installed on their computer (this path is used to find the location of an exe written to my batch file. For the sake of distribution, assume every computer that is installing my application has this program installed in something like C:\Program Files\Blahblah) and then asks the user where they want to install my program. Since the script creates and destroys many files during its lifetime, I want this folder to basically act like the folder I have on my desktop right now as the "root directory" of my application. I want to know the best practice for implementing and creating an installer for these file paths into my python application to make the script easy to distribute to any computer running Windows. Thanks!

iexpress assistance for my program

ok so i've used iexpress a few times without a problem. i created a nice little program for my buddies and i and i'm now in the process of creating a installation package for it. i like iexpress cause it makes it easy and has the license agreement window n whatnot.
ok so program is made. using windows & iexpress i attempt to make the installer, problem is there is one folder that contains an item i need and it needs to be in that folder directory when the installed program needs to run. Problem: i can select files but not folders for the list of items to be in the installer.
Question: how do i include the folder in the install package so there doesnt need to be a few more additional steps for the installation.
i have thought about zipping it, but there isnt a way (that i know of) to add a extract command after the initial install extract.
i figure installers are to programs what instruction booklets are to Ikea furniture so i figured this would be the best place for help. tyvm
iexpress doesn't let you include folders, but you can include a batch file, which may create folders and copy files to the respective folder. To run a batch file, specify cmd /c IncludedBatchFile.bat under Install Program in the iexpress wizard.

Python install creator

Hi i want to build an install creator for my programs in Python.
I have made code for the information gathering, PATHS, FILES, PICS etc.
Now i need to:
Compress the files for the program.
make a config file with install paths ect.
make code for the INSTALLER (i have that to)
Finally i need to "pack" it all in an .exe file that will run the first window in my INSTALLER CODE, so that it will work as my own custom made installer.
Does anybody have any idea how to go about this EASY??
My biggest problem is to collect it all in ONE .exe file that will run my windows(TK code) and of course install my program when clicked...
I have a few ideas how to go about it, BUT in my head these ideas seem to be BIG and NOT EASY, so need ideas for easier solutions.
Update. If i have a program build in python(Tkinter) that will gather the information and save this info as a config file. Then i can build a program that can read this information and extract files ect. accordingly to the info. But how will i combine these configfiles/programs in ONE .exe file that when clicked will run MY program and then accordingly extract my files to the paths in config file. And last use my own icon for the single .exe
If you want to have everything in one exe file, its code needs to be aware of it's content and extract them. This is a problem that has been solved by various tools, eg. see this SO question and its answers.

Distributing python application tutorials

Hi as a python newbie I have written a small python application that can convert an excel worksheet into a sqlite database table. Its not a terribly complex application but it does make use of external modules/package like xlrd (http://pypi.python.org/pypi/xlrd) which I had to download and install when writing my app.
Now that is all done I would like to distribute it amongst my friends, all windows users, while they have python on their machines, they may or may not have the xlrd modules.
I would like to package my app, make sure it includes everything that it needs to run, and share the final .zip file with my friends so they can use the application. Is there a good tutorial that covers how to package a python application, with all the necessary external modules/packages, so that another windows user, can easily run my application.
I keep hearing about disutils, can anyone point me to some good tutorials, or any other python packaging tutorials that show how to get everything into a simple easy to distribute file.
Many thanks
Note: I also want to include the sqlite database file with my application, so the end user doesn't have to worry about anything
First download Pyinstaller and save it somewhere. Then, if you're running Python 2.6 or 2.7 go and install pywin32.
Go create a directory for your output file.
Open Command prompt and enter the fallowing:
python path/to/pyinstaller/pyinstall.py file/to/be/converted.py --onefile
If you want to add an icon, add the --icon argument.
If you want it to hide the CMD window add the --windowed argument.
So if you wanted it to use an icon and hide the CMD window it would look like this:
python path/to/pyinstaller/pyinstall.py file/to/be/converted.py --onefile --icon="path/to/icon.ico" --windowed
The --onefile argument makes the saves everything into one file, without it, the output would be would be a lot of files.
The output is saved in the "dist" folder in the directory it was using.
After you convert the python script in to an .exe, put it in a .zip file along with any other files you need (in your case the squite database file) and you can give it to anyone without them needing to have Python at all.
If you want a program to do this all for you, you can download a program called PTEC.

Categories