Sign in to follow this  
Followers 0
SlowCoder74

Making smaller EXEs?

11 posts in this topic

I see that UPX is able to compress the header of my compiled executables.

Say I create a program with just 1 'shutdown' command, and compile it. The size is 635KB without UPX. With UPX it's 296KB. 635KB is HUGE, especially for just one command. UPX greatly reduces it by about 50%, but even at 296KB, that's pretty big for such a simple program.

What else can be done to shrink a file even smaller? Is there a way to only include required components of the header?

Share this post


Link to post
Share on other sites



645KB is huge? I don't think so. The exe you see is a package of the AutoIt script interpreter and your source code.

If you use UDFs I recommend to use Obfuscator to get rid of unused code.

But you won't get the exe smaller than 300KB.

But that's no problem with the disks you have nowadays.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

On a 1GB flash drive, pretty small for a flash drive these days, you can fit over 1600 files if each file is 635KB. Where's the problem again?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Remember that you only need 1 interpreter, if your package consists of multiple scripts, then compile 1 to exe and everything else to a3x and you'll save quite a bit.

1 person likes this

Share this post


Link to post
Share on other sites

You can use a DOS Batch file or a visual basic script file to have a smaller file for shutting down your PC. Or just do NOT compile the AutoIt script, :D

If you want a smaller exe file, you have to use c/c++ language, but as mentioned above, size is now problem nowadays!


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

What else can be done to shrink a file even smaller?

Use another programming language which can do compilation to native not interpreted code.

Also look here:

http://www.autoitscript.com/trac/autoit/wiki/AutoItNotOnToDoList

Modularized Compilation/variable sized compiled files: ...

Share this post


Link to post
Share on other sites

645KB is huge? I don't think so. The exe you see is a package of the AutoIt script interpreter and your source code.

If you use UDFs I recommend to use Obfuscator to get rid of unused code.

But you won't get the exe smaller than 300KB.

But that's no problem with the disks you have nowadays.

I think of it this way ... I'm probably only using 1/100th of the actual interpreter code to run a simple command like "shutdown". Therefore I was inquiring if there was a way to trim/remove the unused portions. I guess something like the obfuscator you mentioned, but for the interpreter.

One of my projects at work is a tool that needs access to UAC for only some functions, but not others. An older version of it is being used by IT throughout our division, and works good on XP. Now I'm working on Win7 compatibility, and UAC gets in the way. The tool needs to be exactly 1 executable, downloaded via web. Unless I want UAC bugging people every time they run it, I've found that it's necessary to have 2 executables. Therefore, I've come up with the idea to piggyback the UAC enabled executable on the main one. When needed, the main EXE will extract the piggybacked one to the temp folder, and execute it. If a single EXE has a minimum size of 300KB, then I'm looking at a minimum of 600KB, probably closer to 700-800K once combined.

You can use a DOS Batch file or a visual basic script file to have a smaller file for shutting down your PC. Or just do NOT compile the AutoIt script, :D

If you want a smaller exe file, you have to use c/c++ language, but as mentioned above, size is now problem nowadays!

I appreciate the input, but the "shutdown" was just an example to demonstrate the use of a single command. I could have used 'msgbox(0,"","Hi")', just the same.

Share this post


Link to post
Share on other sites

Even a web download of 700KB shouldn't be a problem.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

See post #4 for the answer to your "problem". Compile the second script to an .a3x file, use the first file to run the second file, see the command line references in the help file on how to do that.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

See post #4 for the answer to your "problem". Compile the second script to an .a3x file, use the first file to run the second file, see the command line references in the help file on how to do that.

Will do.

Thank you all!

Share this post


Link to post
Share on other sites

Assembly.

Learn it. Use it. Die a spartan in the programming world.

1 person likes this

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0