Announcement

Collapse
No announcement yet.

Convert AVG installation batch file to VBS script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert AVG installation batch file to VBS script

    I'm having problems getting the AVG batch file working on windows deployment services.
    After a bit of research it seems as batch files don't work on windows deployment services, so it'll need to be converted into a VBS one.
    I don't really need the x64 so the first part could be cut down.
    I have written in red instead of the file path as I can't post links on my first post.
    Could anyone please help with this:

    Code:
    @ECHO OFF
    REM AVG Setup Batch
    IF NOT DEFINED PROCESSOR_ARCHITEW6432 (
    IF %PROCESSOR_ARCHITECTURE% EQU x86 (
    SET SETUP="here goes the path to x32 exe file"
    ) ELSE (
    SET SETUP="here goes the path to x64 exe file"
    )) ELSE (
    SET SETUP="here goes the path to x64 exe file"
    )
    IF NOT EXIST %SETUP% GOTO NoSetup
    REM Start AVG Setup
    %SETUP% /ConfigFilePath="here is setup.ini file path" /MandatoryOnly /AvgCfgFilePath="%CD%\remoteinst.pck" %1 %2 %3 %4 %5 %6 %7 %8 %9
    if %ERRORLEVEL% EQU 1 goto AvgErr
    goto End
    :AvgErr
    ECHO Error while installing AVG
    goto End
    :WrongPlatform
    ECHO Installation file does not support this OS platform(x86 vs x64)
    goto End
    :NoSetup
    ECHO Missing installation files
    REM Continue batch processing
    :End
    ECHO setup returned %ERRORLEVEL%
    Thank you!
    Last edited by Rems; 27th January 2012, 19:12.

  • #2
    Re: Convert AVG installation batch file to VBS script

    Moved from Coffee Lounge to Scripting
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Convert AVG installation batch file to VBS script

      not tested it, but you try this *.vbs script
      Code:
      Set fso = CreateObject( "Scripting.FileSystemObject" )
      
      ' Define Variables,
      pck    = fso.GetParentFolderName(Wscript.ScriptFullName) & "\remoteinst.pck"
      SETUP  = "here goes the path to x32 exe file"
      INI    = "here goes the full path to setup.ini file"
      
      strComputer = "."
      
      
      Set objWMIService = GetObject _
          ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
      
      REM Start AVG Setup
      ErReturn = objWMIService.Create( _
         """" & SETUP & """ /ConfigFilePath=""" _
         & INI & """ /MandatoryOnly /AvgCfgFilePath=""" _
         & pck & """", null, null, intProcessID)
      
      REM On Error
      If ErReturn <> 0 Then
         CreateObject("WScript.Shell") _
           .Popup  "AVG setup not started.", 3, ErReturn , 0+48+4096
      
      Else
         CreateObject("WScript.Shell") _
           .Popup  "AVG setup in progress.", 1, intProcessID , 0+64
      End If
      
      wscript.quit 0
      assuming the file "remoteinst.pck" is in the script's folder (?)


      alternatively,
      Use a vbs script to launch your batch as it is,
      Code:
      strComputer = "."
      
      MYBATCH = "here goes the path to my batch file"
      
      If Wscript.Arguments.Count = 0 Then
          parameters = Empty
      Else
         Dim arrparameters()
         For i = 0 to Wscript.Arguments.Count - 1
           Redim Preserve arrparameters(i)
           arrparameters(i) = """" & Wscript.Arguments(i) & """"
         Next
         parameters = join(arrparameters, " ")
      End If
      
      Set objWMIService = GetObject _
          ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
      
      REM Start the AVG batch
      ErReturn = objWMIService.Create( _
         """" & MYBATCH & """ " & parameters, null, null, intProcessID)
      
      wscript.quit 0
      NOTE, in your batch the %CD% variable is used, it points to the 'current directory'. However the current directory can never be a network path. If you like pointing the batch location (?) then instead of %CD% use: %~0\..\ or %~dp0 (i.e. %~dp0remoteinst.pck ).



      /Rems
      Last edited by Rems; 31st January 2012, 10:55.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Convert AVG installation batch file to VBS script

        Nice one, thank you.
        I'll give it a shot.
        I wouldn't be able to script that kind on my own.

        Comment

        Working...
        X