Friday, May 22, 2009

Making the AVG batch file into a single-file exe.

In my previous post, I made a batch file to automatically install AVG. Previously I would zip this .bat+.ini+.exe combination and send it to the Users. In a perfect world, the users open the zip and run the batch file. In the real world, the users will run the executable instead of the batch file. Even when it is named NoNotThisFilePlease.exe. This time I am going to make it user resistant. I am going to wrap it into a single .exe installer.

There are a number of commercial self-extracting installer products out there. I really like Paquet Builder. Unfortunately it is $50. That is about $40 more than I'm willing to pay.

To do this for FREE you need the 7-zip installer and "7z Library, SFXs for installers, Plugin for FAR Manager" from the 7-zip download page. Also you may optionally want Resource Hacker. This lets you change the .EXE icon to something pretty.

Procedure:
  1. Install 7-zip.
  2. Open the folder with the batch file and files.
  3. Compress the files into archive.7z
    1. Select the require files
    2. right-click, 7-Zip, Add To Archive.
    3. Name the 7-zip file archive.7z.
    4. The avg installer is already well compressed so the best compression method for it is just "store". It makes decompression fast too.
  4. Open the 7-zip extras package and copy 7zSD.sfx and config.txt into the same directory as the archive.7z folder. The config.txt file is in the /installer directory.
  5. Edit config.txt and change it to run your batch file. Here is my example.

    ;!@Install@!UTF-8!
    Title="GlobalOptions AVG8 Distributable v1.0"
    BeginPrompt="Do you want to install AVG8?"
    RunProgram="AVGSetup.Bat"
    ;!@InstallEnd@!
  6. Finally "compile" the self-extracting EXE. This is actually just concatenating the files together.
    1. Open a command prompt.
    2. Change to the directory with archive.7z, 7zsd.sfx, and config.txt
    3. Run this command.
      copy /b 7zSD.sfx + config.txt + archive.7z AvgSetup.exe

That's it. That command copies the .sfx "stub", the config file, and the archive into a single .EXE file.

Finally and optionally the .exe needs a pretty icon. :D For Anti-virus software I am rather fond of this one. "Symbol". Note: it is not free for commercial use.

To change the icon:
  1. Open ResHack.exe.
  2. File-> Open -> open the executable.
  3. Expand the "icon" group and expand Icon 1.
  4. Right-click the icon and select Replace Resource.
  5. Click "Open File with new Icon".
  6. Navigate to your .ico file.
  7. Click Replace.
  8. Save the executable.


That's it,

I hope this helps,

-Ellie

1 comment:

Anonymous said...

Do you know how I could deploy AVG Business Edition with group policy? I need to do an unattended installation that runs on startup. I've experimented with the avgagent but I seem to be missing some steps. Thanks for your help!