6 Replies Latest reply on Jun 9, 2010 9:20 AM by Erik

    ePO Agent Installation - VBSCRIPT login script

      I recall reading a post a while back about login scripts and someone had some batch files put together. I began thinking through the logic of the batch file and while good, I felt that some of the registry checking could be better served through .vbs then extracting reg contents to a text file.

      Below is what I came up with, feel free to use it or modify it to fit your needs.

      Option Explicit

      '==================================
      ' Created by Brad S
      ' suderman@friends.edu
      ' 04/15/2009
      '
      ' The script will check to see if the agent is installed, the current version, and the ePO
      ' server IP address. If any of the above mentioned items are incorrect according to your
      ' variables, the new agent will be installed.
      '==================================

      '==================================
      ' Variable Declarations
      '==================================
      Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist

      Dim REQUIRED_AGENT_VERSION
      Dim REQUIRED_SERVER_IP
      Dim INSTALL_PATH
      DIM STR_PARAMETERS

      '======================================
      ' MUST CHANGE VARIABLES IN THIS SECTION
      '======================================

      REQUIRED_AGENT_VERSION="x.x.x.x"
      REQUIRED_SERVER_IP="x.x.x.x:x"
      INSTALL_PATH ="\\path\to\your\framepkg.exe"
      STR_PARAMETERS = ""

      '======================================
      ' END CHANGE VARIABLES SECTION
      '======================================

      'HKEY_CURRENT_USER = HKCU
      'HKEY_LOCAL_MACHINE = HKLM
      'HKEY_CLASSES_ROOT = HKCR
      'HKEY_USERS = HKEY_USERS
      'HKEY_CURRENT_CONFIG = HKEY_CURRENT_CONFIG


      Const HKEY_CURRENT_USER = &H80000002

      CheckRegExist()

      If (regExist=TRUE) Then

      '==================================
      ' Get Registry Values
      '==================================

      agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework\Version")
      'WScript.Echo "Agent Version: " & agentVersion

      dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework\Data Path")
      'WScript.Echo "Data Path: " & dataPath


      '==================================
      ' Read XML Sitelist
      '==================================

      Set xmlDoc = CreateObject("Msxml2.DOMDocument")
      xmlDoc.load(dataPath & "\SiteList.xml")

      Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
      ipAddress = ElemList.item(0).getAttribute("ServerIP")
      'MsgBox ipAddress


      '==================================
      ' Check Agent Version, ServerIP
      '==================================

      IF (agentVersion<>REQUIRED_AGENT_VERSION) OR (ipAddress<>REQUIRED_SERVER_IP) THEN

      InstallNewAgent(INSTALL_PATH)

      'MsgBox("Your agent is now up to date and configured correctly.")

      ELSE

      'MsgBox("Your agent is currently up to date and configured correctly.")

      END IF

      'Install Agent if Reg Does NOT exist

      ELSE
      InstallNewAgent(INSTALL_PATH)
      END IF


      '==================================
      ' Registry Reader
      '==================================

      Function ReadReg(RegPath)
      Dim objRegistry, Key
      Set objRegistry = CreateObject("Wscript.shell")
      Key = objRegistry.RegRead(RegPath)
      ReadReg = Key
      End Function


      '==================================
      ' Agent Installation
      '==================================

      Function InstallNewAgent(INSTALL_PATH)
      Dim wshShell
      Set wshShell = WScript.CreateObject ("WSCript.shell")

      'MsgBox("Installing New Agent...")

      wshshell.run INSTALL_PATH, 6, True
      set wshshell = nothing
      End Function

      '==================================
      ' Check if Reg Key Exists
      '==================================

      Function CheckRegExist ()
      Dim strComputer, objRegistry, strKeyPath, strValueName, dwValue
      strComputer = "."
      Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

      strKeyPath = "SOFTWARE\Network Associates\TVD\Shared Components\Framework"
      strValueName = "Version"

      objRegistry.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

      If IsNull(dwValue) Then
      'Wscript.Echo "The registry key does not exist."
      regExist=FALSE
      Else
      'Wscript.Echo "The registry key exists. (" & dwValue & ")"
      regExist=TRUE
      End If
      End Function


      The one problem I found is that when you call the installation of the new agent via framepkg.exe, it gives a 'parameters incorrect' error message. The way I worked around this was to put the following code into a batch file (saved in the same directory as your framepkg.exe) and call it through the "INSTALL_PATH" variable in the script:
      "\\serverName\Mcafee\Agent\FramePkg.exe" /FORCEINSTALL /INSTALL=AGENT /INSTDIR="%PROGRAMFILES%\McAfee\Common Framework" /SILENT


      If anyone can shed any light on why it would give that error, please chime in!

      Anyways, for what it's worth, help yourselves.
        • 1. RE: ePO Agent Installation - VBSCRIPT login script
          Nice script file.

          When I pushed out my agents via batch file I used the reg query command to check if the agent was installed:

          REG QUERY "HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent" /v AgentGUID


          It's a down and dirty way to check for the agent's existence, based on the error level returned the file then went to the install routine or exited.
          • 2. RE: ePO Agent Installation - VBSCRIPT login script
            That could work but there was more I wanted to check for.
            I wanted to make sure the agent was the latest version, the correct server IP address, etc.

            The latest thing that has stumped me is how to check for duplicate GUID numbers...
            • 3. update
              A little update - this version utilizes the STR_PARAMETER variable.
              Also, a side note: In order for the script to recognize quotations in the command line, you must include the Chr(34) in your string (see below - line 30).

              The reason I include quotes in the INSTALL_PATH is in case there is a space in your file path, the cmd call will not work without them.

              Option Explicit

              '==================================
              ' Created by Brad S
              ' suderman@friends.edu
              ' 04/15/2009
              '
              ' The script will check to see if the agent is installed, the current version, and the ePO
              ' server IP address. If any of the above mentioned items are incorrect according to your
              ' variables, the new agent will be installed.
              '==================================

              '==================================
              ' Variable Declarations
              '==================================
              Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist

              Dim REQUIRED_AGENT_VERSION
              Dim REQUIRED_SERVER_IP
              Dim INSTALL_PATH
              Dim STR_PARAMETERS
              Dim FULL_INSTALL_PATH

              '======================================
              ' MUST CHANGE VARIABLES IN THIS SECTION
              '======================================

              REQUIRED_AGENT_VERSION="4.0.0.1180"
              REQUIRED_SERVER_IP="10.1.10.30:80"
              INSTALL_PATH = Chr(34) & "\\server\installpath\framepkg.exe" & Chr(34)
              STR_PARAMETERS = " /FORCEINSTALL /INSTALL=AGENT /INSTDIR=" & Chr(34) & "%PROGRAMFILES%\McAfee\Common Framework\" & Chr(34) & " /SILENT"
              FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS)

              '======================================
              ' END CHANGE VARIABLES SECTION
              '======================================

              Const HKEY_LOCAL_MACHINE = &H80000002

              CheckRegExist()

              If (regExist=TRUE) Then

              '==================================
              ' Get Registry Values
              '==================================

              agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework\Version")
              'WScript.Echo "Agent Version: " & agentVersion

              dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework\Data Path")
              'WScript.Echo "Data Path: " & dataPath


              '==================================
              ' Read XML Sitelist
              '==================================

              Set xmlDoc = CreateObject("Msxml2.DOMDocument")
              xmlDoc.load(dataPath & "\SiteList.xml")

              Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
              ipAddress = ElemList.item(0).getAttribute("ServerIP")
              MsgBox ipAddress


              '==================================
              ' Check Agent Version, ServerIP
              '==================================

              IF (agentVersion<>REQUIRED_AGENT_VERSION) OR (ipAddress<>REQUIRED_SERVER_IP) THEN

              InstallNewAgent(FULL_INSTALL_PATH)

              'MsgBox("Your agent is now up to date and configured correctly.")

              ELSE

              'MsgBox("Your agent is currently up to date and configured correctly.")

              END IF

              'Install Agent if Reg Does NOT exist

              ELSE
              InstallNewAgent(FULL_INSTALL_PATH)
              END IF


              '==================================
              ' Registry Reader
              '==================================

              Function ReadReg(RegPath)
              Dim objRegistry, Key
              Set objRegistry = CreateObject("Wscript.shell")
              Key = objRegistry.RegRead(RegPath)
              ReadReg = Key
              End Function


              '==================================
              ' Agent Installation
              '==================================

              Function InstallNewAgent(FULL_INSTALL_PATH)
              Dim wshShell
              Set wshShell = WScript.CreateObject ("WSCript.shell")

              'MsgBox("Installing New Agent...")

              wshshell.run FULL_INSTALL_PATH, 6, True
              set wshshell = nothing
              End Function

              '==================================
              ' Check if Reg Key Exists
              '==================================

              Function CheckRegExist ()
              Dim strComputer, objRegistry, strKeyPath, strValueName, strValue
              strComputer = "."
              Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

              strKeyPath = "SOFTWARE\Network Associates\TVD\Shared Components\Framework"
              strValueName = "Version"

              objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

              If IsNull(strValue) Then
              'Wscript.Echo "The registry key does not exist."
              regExist=FALSE
              Else
              'Wscript.Echo "The registry key exists. (" & strValue & ")"
              regExist=TRUE
              End If
              End Function
              • 4. RE: update
                Hi Brad,

                Thanks for the script! I'm thinking about using it to distribute software via Group Policy. Just curious if there was a particular reason why your CheckRegExist subroutine checks under HKCU instead of HKLM?
                • 5. RE: update
                  Very good observation. I actually was visiting with someone about this script yesterday and noticed that as well. I will correct it here.
                  • 6. Re: ePO Agent Installation - VBSCRIPT login script
                    Erik

                    Hi, I tweaked it a little bit further as the sitelist.xml of agent 4.5 now can contain multiple spipesites, due to the agenthandler functionality. Set the correct ip-address of your server/handlers separated by a comma (or any other character) and they will all be evaluated.

                     

                    Option Explicit
                    '==================================
                    ' Created by Brad S
                    ' suderman@friends.edu
                    ' 04/15/2009
                    ' 
                    ' Edited by Medusoft
                    ' support@medusoft.eu
                    ' 06/09/2010
                    '
                    ' The script will check to see if the agent is installed, the current or a newer version, 
                    ' and the ePO server IP address. If any of the above mentioned items are incorrect 
                    ' according to your variables, the new agent will be installed.
                    '==================================
                    
                    '==================================
                    ' Variable Declarations
                    '==================================
                    Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist
                    Dim REQUIRED_AGENT_VERSION
                    Dim REQUIRED_SERVER_IP
                    Dim INSTALL_PATH
                    Dim STR_PARAMETERS
                    Dim FULL_INSTALL_PATH
                    
                    '======================================
                    ' MUST CHANGE VARIABLES IN THIS SECTION
                    '======================================
                    REQUIRED_AGENT_VERSION="4.5.0.1270"
                    REQUIRED_SERVER_IP="10.0.2.9:10001,213.207.93.159:10001"
                    INSTALL_PATH = Chr(34) & "\\kuiken\netlogon\mcafee\framepkg.exe" & Chr(34)
                    STR_PARAMETERS = " /FORCEINSTALL /INSTALL=AGENT /INSTDIR=" & Chr(34) & "%PROGRAMFILES%\McAfee\Common Framework\" & Chr(34) & " /SILENT"
                    FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS)
                    
                    '======================================
                    ' END CHANGE VARIABLES SECTION
                    '======================================
                    Const HKEY_LOCAL_MACHINE = &H80000002
                    CheckRegExist()
                    If (regExist=TRUE) Then
                    
                    '==================================
                    ' Get Registry Values
                    '==================================
                    agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework\Version")
                    'WScript.Echo "Agent Version: " & agentVersion
                    dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework\Data Path")
                    'WScript.Echo "Data Path: " & dataPath
                    
                    '==================================
                    ' Read XML Sitelist
                    '==================================
                    Set xmlDoc = CreateObject("Msxml2.DOMDocument")
                    xmlDoc.load(dataPath & "\SiteList.xml")
                    Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
                    ipAddress = ElemList.item(0).getAttribute("ServerIP")
                    'MsgBox ipAddress & " " & InStr(REQUIRED_SERVER_IP,ipAddress)
                    
                    '==================================
                    ' Check Agent Version, ServerIP
                    '==================================
                    IF (agentVersion<REQUIRED_AGENT_VERSION) OR InStr(REQUIRED_SERVER_IP,ipAddress) < 1 THEN 
                     InstallNewAgent(FULL_INSTALL_PATH) 
                     'MsgBox("Your agent is now up to date and configured correctly.")
                    ELSE 
                     'MsgBox("Your agent is currently up to date and configured correctly.")
                    END IF
                     'Install Agent if Reg Does NOT exist 
                    ELSE 
                     InstallNewAgent(FULL_INSTALL_PATH)
                    END IF
                    
                    '==================================
                    ' Registry Reader
                    '==================================
                    Function ReadReg(RegPath) 
                     Dim objRegistry, Key 
                     Set objRegistry = CreateObject("Wscript.shell") 
                     Key = objRegistry.RegRead(RegPath) 
                     ReadReg = Key
                    End Function
                    
                    '==================================
                    ' Agent Installation
                    '==================================
                    Function InstallNewAgent(FULL_INSTALL_PATH) 
                     Dim wshShell 
                     Set wshShell = WScript.CreateObject ("WSCript.shell") 
                     ' MsgBox("Installing New Agent...") 
                     wshshell.run FULL_INSTALL_PATH, 6, True 
                     set wshshell = nothing
                    End Function
                    
                    '==================================
                    ' Check if Reg Key Exists
                    '==================================
                    Function CheckRegExist () 
                     Dim strComputer, objRegistry, strKeyPath, strValueName, strValue 
                     strComputer = "." 
                     Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") 
                     strKeyPath = "SOFTWARE\Network Associates\TVD\Shared Components\Framework" 
                     strValueName = "Version" 
                     objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue 
                     If IsNull(strValue) Then 
                     'Wscript.Echo "The registry key does not exist." 
                     regExist=FALSE 
                     Else 
                     'Wscript.Echo "The registry key exists. (" & strValue & ")" 
                     regExist=TRUE 
                     End If
                    End Function