Create and Sign an EXE with Python
·Jan 27, 2021·
1 min read
The contents of this post are no longer useful.
If you want to turn your python procedure into a signed executable in Windows, just follow the steps below. Note that the strings with captial letters should be changed according to your taste.
- Windows 10 SDK for singtool.exe
- install pyinstaller
pip install pyinstaller
- create an .exe from a .py
pyinstaller /PATH/TO/FILE_TO_COMPILE.py --onefile --noconsole
- create a personal certificate New-SelfSignedCertificate in PowerShell
New-SelfSignedCertificate -DNSName "YOURDOMAIN.COM" -CertStoreLocation Cert:\CurrentUser\My -Type CodeSigningCert -Subject “MY PERSONAL CERTIFICATE”
- sign the .exe with signtool or other GUI supporting tools
signtool sign /a "/PATH/TO/FILE_TO_SIGN.exe"
- In the step #2, --onefile allows pyinstaller to generate only one file, which is an .exe, rather than any others, and --noconsole blocks the console window while executing the .exe.