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

One-Click AVG Installer

AVG is my current favorite Antivirus product. It does what I need it and generally stays out of the way. Unfortunately the version upgrade from 7.5 to 8.0 has no upgrade path for our 160 users that are A.) Remote B.) Not on a domain and C.) not on a VPN.

Thanks so much Grisoft. Really, Thanks.

So anyway I installed the new datacenter software, AVG Admin 8 and got it all setup. For the users in AD we rolled it out and now we have to figure out how to upgrade all the remote users.

I went through the AVG wizard to create an installer. That got me a batch file and a .ini file for the installer. I edited the batch file and .INI to install it with our preferences. When finished I ended up with a .bat file that the users can run to install the app.

AvgSetup.bat

@ECHO OFF
echo This application will automatically install AVG 8.0.
echo Please wait. This window will automatically close
echo when the installation is complete.

SET SETUP="%CD%\Setup\avg_ipw_stf_all_85_339a1525.exe"
%SETUP% /SCRIPT_FILE "%CD%\AvgSetup.ini" %1 %2 %3 %4 %5 %6 %7 %8 %9
echo.
echo.
Echo Setup is complete. If the AVG icon is not visible on your taskbar, then please reboot your PC now.
pause


AvgSetup.ini

LICNO: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
RESTART:
KILL_PROCESS_IF_NEEDED:
QUIT_IF_INSTALLED:
NAME: "MyCompany"
COMPANY: "MyCompany"
DCPATH: "avg.example.com:4158"
NOAVGTOOLBAR:
ADD_FEATURE: fea_AVG_HttpScanner
ADD_FEATURE: fea_AVG_SafeSurf
ADD_FEATURE: fea_AVG_SafeSearch
ADD_FEATURE: fea_AVG_Exchange_plugin
ADD_FEATURE: fea_AVG_EMC
ADD_FEATURE: fea_AVG_Office_2000_plugin
ADD_FEATURE: fea_AVG_Cl
NO_WELCOME:


That's it. Now we have a one-click installer for a fully configured AVG application.

Check out my next post for how to make this a user-resistant install.