1 Reply Latest reply on Dec 17, 2013 9:09 AM by Peter M

    vbs script to look for more than one registry path!

    kimzi

      Hey you, Guys!

       

      I have been working on a vbs script to update the McAfee agent on x86 machines, though I now bumped into a problem.

      While using the registry to see if the computer has the latest version I also need to check if they happen to NOT have any anti virus at all on the computer.

       

      Right now I've got this:

       

       

      Set objExplorer = CreateObject("InternetExplorer.Application")
      
      objExplorer.Navigate "about:blank" 
      objExplorer.ToolBar = 0
      objExplorer.StatusBar = 0
      objExplorer.Height = 200
      objExplorer.Width = 400
      objExplorer.Visible = 1 
      objExplorer.Document.Title = "Anti-Virus script in progress"
      
      objExplorer.Document.Body.InnerHTML = "Searching for Anti-Virus, updating if needed. " _
       & "This might take several minutes to complete."
          WScript.Sleep 10000
      Set objShell = CreateObject("WScript.Shell") 
      Set WshShell = CreateObject("WScript.Shell")
      
      Const HKEY_LOCAL_MACHINE = &H80000002
      Dim objReg, strComputer, strKeyPath, strValueName, strValue
      strComputer = "."
      
      Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
      
      strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1FDB8EC6-BAF1-42F9-8E09-4D9AB369F1B5}"
      strValueName = "DisplayVersion"
      objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
      If IsNull(strValue) Then 
      
          objExplorer.Document.Body.InnerHTML = "Older version of McAfee found, uninstalling..."
          WshShell.Run "msiexec /x {147BCE03-C0F1-4C9F-8157-6A89B6D2D973} /passive",1,true
          WScript.Sleep 5000
          WshShell.Run "msiexec /x {36FE3EDA-0C18-48DE-934B-D9862F82A7A8} /passive",1,true
          WScript.Sleep 5000
          objExplorer.Document.Body.InnerHTML = "Installing new Anti-Virus"
          strCommand = Chr(34) & "\\Myserver\NETLOGON\Framepkg.exe"
          objShell.Run strCommand, 1, True
          Wscript.Sleep 5000
          objExplorer.Document.Body.InnerHTML = "Install Complete"
          WScript.Sleep 5000
      
          objExplorer.Quit
      
      Else
      
          objExplorer.Document.Body.InnerHTML = "Current version of McAfee found, the script will now quit."
          Wscript.Sleep 3000
      
          objExplorer.Quit
              Wscript.Quit
      
      End If
      

       

      As you may see the script do look for one key, and depending on the existece of this key it either removes/installs or quits.

      Everything works the way it's intended except I need to look for at least one more / maybe several key paths as I noticed all versions use different paths.

      Someone who can help me with this? I'm feeling like I should get this but I cant seem to come up with a solution.

       

      Best Regards

      Kimzi

       

      Message was edited by: kimzi on 12/17/13 8:36:51 AM CST

       

      on 12/17/13 8:37:22 AM CST