Table of Contents

**AVG Antivirus**

Tested with opsi 4.0.1
requiredWinstVersion >= “4.10.8.6”
For 32 and 64 Bit
Installation files at http://free.avg.com/de-de/download-free-all-product

questions to: Thomas_H 2011/10/27 10:30

history:
changed: — Thomas_H 2013/07/15 11:21

This is the installation-script for AVG-Antivirus (Free), but it should also function with the payed version. If you have any experiences with the payed version combined with these scripts please let us know by the discussion-page.

Tree:

avg.jpg\\
avg_x32.exe (the renamed downloaded setup-file for 32 Bit)\\
avg_x64.exe (the renamed downloaded setup-file for 64 Bit)\\
checkendofinstall.bat\\
delsub.ins\\
setup.ins\\
uninstall.ins

setup.ins

; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
 
[Initial]
LogLevel=9
;  Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; let started programs run in front of the winst window
StayOnTop=false
 
 
[Actions]
requiredWinstVersion >= "4.10.8.6"
 
DefVar $UninstallProgram32$
DefVar $UninstallProgram64$
DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstallDir32$
DefVar $InstallDir64$
DefVar $ExitCode$
DefVar $LicenseRequired$
DefVar $LicenseKey$
DefVar $LicensePool$
DefVar $INST_SystemType$
DefVar $INST_architecture$
DefVar $Version$
DefVar $Inst_Cmd$
DefVar $Inst_Prg32$
DefVar $Inst_Prg64$
DefVar $Uninst_Cmd$
DefVar $Uninst_Prg$
 
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
Set $LogDir$ = "%SystemDrive%\tmp"
 
; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
;$ProductId$ should be the name of the product in opsi
; therefore please: only lower letters, no umlauts,
; no white space use '-' as a seperator
Set $ProductId$       = "avg"
Set $Version$         = "2012"
Set $MinimumSpace$    = "30 MB"
; the path were we find the product after the installation
Set $InstallDir32$      = "%ProgramFiles32Dir%\avg"
Set $InstallDir64$      = "%ProgramFiles64Dir%\avg"
Set $LicenseRequired$ = "false"
Set $LicensePool$     = "p_" + $ProductId$
Set $Inst_Prg32$ = "avg_free_x86.exe"
Set $Inst_Prg64$ = "avg_free_x64.exe"
Set $Inst_Cmd$ = '/UILevel=silent /InstallToolbar=0 /ChangeBrowserSearchProvider=0 /InstallSidebar=0 /ParticipateProductImprovement=0 /DontRestart'
 
Set $Uninst_Cmd$ = " /AppMode=SETUP /Maintenance=2 /UILevel=silent"
Set $Uninst_Prg$ = "\AVG10\avgmfapx.exe"
; ----------------------------------------------------------------
 
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
        LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
        isFatalError
        ; Stop process and set installation status to failed
else
        comment "Show product picture"
        ShowBitmap "%ScriptPath%\" + $ProductId$ + ".jpg" $ProductId$
 
        if FileExists("%ScriptPath%\delsub.ins")
                comment "Start uninstall sub section"
                Sub "%ScriptPath%\delsub.ins"
        endif
 
        if $LicenseRequired$ = "true"
                comment "Licensing required, reserve license and get license key"
                Sub_get_licensekey
        endif
 
        comment "Installiere AVG..."
 
        if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
                Message "Installiere " + $ProductId$ + ". Das kann 15 Min dauern, bitte Geduld..."
                comment "Start setup program"
                Winbatch_install_32
                Sub_check_exitcode
                ExitWindows /Reboot
        endif
 
        if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
                Message "Installiere " + $ProductId$ + ". Das kann 15 Min dauern, bitte Geduld..."
                comment "Start setup program"
                Winbatch_install_64
                Sub_check_exitcode
                ExitWindows /Reboot
        endif
 
endif
 
[Winbatch_install_32]
%ScriptPath%\$Inst_Prg32$ $Inst_Cmd$
"%ScriptPath%\checkendofinstall.bat"
 
[Winbatch_install_64]
%ScriptPath%\$Inst_Prg64$ $Inst_Cmd$
"%ScriptPath%\checkendofinstall.bat"
 
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
        comment "Looks good: setup program gives exitcode zero"
else
        comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
        if ($ExitCode$ = "1605")
                comment "ERROR_UNKNOWN_PRODUCT  1605    This action is only valid for products that are currently installed."
                comment "Uninstall of a not installed product failed - no problem"
        else
                if ($ExitCode$ = "1641")
                        comment "looks good: setup program gives exitcode 1641"
                        comment "ERROR_SUCCESS_REBOOT_INITIATED 1641    The installer has initiated a restart. This message is indicative of a success."
                else
                        if ($ExitCode$ = "3010")
                                comment "looks good: setup program gives exitcode 3010"
                                comment "ERROR_SUCCESS_REBOOT_REQUIRED  3010    A restart is required to complete the install. This message is indicative of a success."
                        else
                                logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
                                isFatalError
                        endif
                endif
        endif
endif

uninstall.ins

[Initial]
LogLevel=9
;  Log Errors in Logfile but don't abort:
ExitOnError=false
; Show syntax errors in the script:
ScriptErrorMessages=on
; Dont trace step by step through the script:
TraceMode=off
; let started programs run in front of the winst window
StayOnTop=false
 
[Actions]
requiredWinstVersion >= "4.10.8.6"
 
DefVar $UninstallProgram32$
DefVar $UninstallProgram64$
DefVar $LogDir$
DefVar $ExitCode$
DefVar $ProductId$
DefVar $InstallDir32$
DefVar $InstallDir64$
DefVar $LicenseRequired$
DefVar $LicensePool$
DefVar $INST_SystemType$
DefVar $INST_architecture$
DefVar $Uninst_Cmd$
DefVar $Uninst_Prg$
 
Set $INST_SystemType$ = GetSystemType
set $INST_architecture$ = GetProductProperty("install_architecture","system specific")
 
 
Set $LogDir$ = "%SystemDrive%\tmp"
 
; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
Set $ProductId$       = "avg"
Set $InstallDir32$    = "%ProgramFiles32Dir%\avg"
Set $InstallDir64$    = "%ProgramFiles64Dir%\avg"
Set $LicenseRequired$ = "false"
Set $LicensePool$     = "p_" + $ProductId$
Set $Uninst_Prg$        = "\AVG10\avgmfapx.exe"
Set $Uninst_Cmd$        = " /AppMode=SETUP /Maintenance=2 /UILevel=silent"
; ----------------------------------------------------------------
 
comment "Show product picture"
ShowBitmap "%ScriptPath%\" + $ProductId$ + ".jpg" $ProductId$
 
Message "Deinstalliere " + $ProductId$ + ". Bitte etwas Geduld..."
 
if FileExists($InstallDir32$+$Uninst_Prg$)
    Set $Uninst_Prg$ = $InstallDir32$+$Uninst_Prg$M
    comment "Start uninstall sub section"
    Sub "%ScriptPath%\delsub.ins"
endif
 
if FileExists($InstallDir64$+$Uninst_Prg$)
    Set $Uninst_Prg$ = $InstallDir64$+$Uninst_Prg$M
    comment "Start uninstall sub section"
    Sub "%ScriptPath%\delsub.ins"
endif
 
 
if $LicenseRequired$ = "true"
        comment "Licensing required, free license used"
        Sub_free_license
endif
 
ExitWindows /Reboot
 
[Sub_free_license]
comment "License management is enabled and will be used"
 
comment "Trying to free license used for the product"
DefVar $result$
Set $result$ = FreeLicense($LicensePool$)
; If there is an assignment of a license pool to the product, it is possible to use
; Set $result$ = FreeLicense("", $ProductId$)
;
; If there is an assignment of a license pool to a windows software id, it is possible to use
; DefVar $WindowsSoftwareId$
; $WindowsSoftwareId$ = "..."
; set $result$ = FreeLicense("", "", $WindowsSoftwareId$)

delsub.ins

; Copyright (c) uib gmbh (www.uib.de)
; This sourcecode is owned by uib gmbh
; and published under the Terms of the General Public License.
; credits: http://www.opsi.org/credits/
 
 
; Wir haben $Uninst_Prg$ bereits mit dem Programmverzeichnis des Betriebssystems verknuepft! Somit ist es bereits "C:\Programme (x86)\blabla\...
 
if (($INST_SystemType$ = "x86 System") and ($INST_architecture$ = "system specific")) or ($INST_architecture$ = "both") or ($INST_architecture$ = "32 only")
        Message "Uninstalling " + $ProductId$ + " 32 Bit..."
 
        if FileExists($Uninst_Prg$)
                comment "Uninstall program found, starting uninstall"
                Winbatch_uninstall_32
                comment "Removing "+$InstallDir32$
;               Files_uninstall_32
                sub_check_exitcode
        endif
Mendif
 
if ($INST_SystemType$ = "64 Bit System") and (($INST_architecture$ = "system specific") or ($INST_architecture$ = "both") or ($INST_architecture$ = "64 only"))
        Message "Uninstalling " + $ProductId$ + " 64 Bit..."
 
        if FileExists($Uninst_Prg$)
                comment "Uninstall program found, starting uninstall"
                ; Die Aufrufe fuer 32 Bit und 64 Bit sind gleich, daher:
                Winbatch_uninstall_32
                comment "Removing "+$InstallDir64$
;               Files_uninstall_64
                sub_check_exitcode
        endif
endif
 
[Winbatch_uninstall_32]
"$Uninst_Prg$" $Uninst_Cmd$
 
 
[Files_uninstall_32]
; Example for recursively deleting the installation directory (don't forget the trailing backslash):
;
;delete -sf "$InstallDir32$\"
 
[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
        comment "Looks good: setup program gives exitcode zero"
else
        comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
        if ($ExitCode$ = "1605")
                comment "ERROR_UNKNOWN_PRODUCT  1605    This action is only valid for products that are currently installed."
                comment "Uninstall of a not installed product failed - no problem"
        else
                if ($ExitCode$ = "1641")
                        comment "looks good: setup program gives exitcode 1641"
                        comment "ERROR_SUCCESS_REBOOT_INITIATED 1641    The installer has initiated a restart. This message is indicative of a success."
                else
                        if ($ExitCode$ = "3010")
                                comment "looks good: setup program gives exitcode 3010"
                                comment "ERROR_SUCCESS_REBOOT_REQUIRED  3010    A restart is required to complete the install. This message is indicative of a success."
                        else
                                logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
                                isFatalError
                        endif
                endif
        endif
endif

checkendofinstall.bat

REM ##############################################################################################
REM ###                                                                                        ###
REM ###  This batchfile checks, if avgmfapx.exe, the following install-file after setup.exe    ###
REM ###  is still running. It will close itself, when avgmfapx is ready. Until then the        ###
REM ###  setup.ins is waiting for the termination of checkendofinstall.bat                     ###
REM ###  Without this batchfile setup.ins will go on right in the moment, the $INST_PRGxx$     ###
REM ###  is closing, and will initiate a reboot, nevertheless AVG Antivir Installation is      ###
REM ###  still in progress. So after e reboot, the AVG is not avail and not installed, but in  ###
REM ###  configed it shows a "success"                                                         ###
REM ###                                                                                        ###
REM ###  batchfile by Thomas_H                                                                 ###
REM ###                                                                                        ###
REM ##############################################################################################
 
@echo off
 
SET FOUND=0
 
 
cls
echo Programm wird installiert, das kann ein Weilchen dauern, bitte warten...
:start
 
 
tasklist | find /i "avgmfapx" >NUL
 
if %errorlevel% == 1 (
    if %FOUND%==1 goto:eof
GOTO :start
)
 
if %errorlevel% == 0 (
    if %FOUND%== 0 set FOUND=1
GOTO:start
)
 
:ende