Auto-compress exe with UPX after creation

Share your advanced PureBasic knowledge/code with the community.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Auto-compress exe with UPX after creation

Post by PB »

DoubleDutch wrote:It would be good if there was a post compressor on the exe, but I'm sure that it can either be added as some kind of automatic tool.
Your wish is my command. :) The following tool is for Windows only.

(1) Download UPX (Win32 console version) from http://upx.sourceforge.net/

(2) Unzip it and put "upx.exe" in your PureBasic folder (next to PureBasic.exe).

(3) Compile the following single line to an exe called "AutoUPX.exe" and put it
somewhere easy and convenient to find (maybe also next to PureBasic.exe?):

Code: Select all

ShellExecute_(0,"",Chr(34)+#PB_Compiler_Home+"upx.exe"+Chr(34),"--best "+Chr(34)+ProgramParameter()+Chr(34),"",#SW_HIDE)
(4) In the IDE, open the "Tools" menu and select the "Configure Tools" item.

(5) Click the "New" button.

(6) Make a new entry that looks like the following, and click the "OK" button
when done. (Make sure the "Commandline" part matches the location where
you stored "AutoUPX.exe").

Image

That's it! Now, whenever you create an executable, UPX will automatically compress it. 8)
Last edited by PB on Thu Mar 26, 2009 11:26 pm, edited 1 time in total.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Nice, thanks. :)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Thanks, this is useful sometimes.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Thank you. This could well come in handy.
I may look like a mule, but I'm not a complete ass.
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Nice one, PB. Thanks.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It's a pity something like this isn't built-in and selectable on a file by file basis.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

Hey PB, can you update the last pic as it isn't showing or just type it? Thanks!
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

Thanks PB. Nice tip.

I've been using the UPX Addon from ts-soft at this topic
http://www.purebasic.fr/english/viewtop ... =upx+addon
but looks like the links are broken.

ts-soft is still around here, so maybe he will update the links. His addon allows configuring UPX too.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Link updated. It's now stored on ImageShack, so should stay there forever.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

PB wrote:Link updated. It's now stored on ImageShack, so should stay there forever.
Thanks! ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
idle
Always Here
Always Here
Posts: 5844
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

thanks PB could be very useful
Post Reply