Jump to content

Making smaller EXEs?


Recommended Posts

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?

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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.
Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...