Announcement

Collapse
No announcement yet.

VBS -- Installing ePOagent with checks

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

  • VBS -- Installing ePOagent with checks

    Any suggestions??

    got already this:

    Code:
    Dim oShell
    Set oShell = CreateObject ("wscript.shell")
    
    If Checkstate = "" Then 			'check of ePOagent is installed....
    	WScript.Echo "Not installed!!!!"
    	WScript.Echo "installing ePOagent...."
    	oShell.Exec ("\\Server01\epoAgent\FramePkg.exe /forceinstall /Silent /install=agent") 
    end if 
    
    If Checkstate = "true" Then			'check of the state is running....
    	WScript.Quit (0)
    End if
    
    If Checkstate = "false" Then		'check if the service could be started...
    	StartService
    End if
    
    
    If Checkstate = "false" Then		'if that doesn't work then reinstall agent..
    	WScript.Echo "Reinstalling ePoagent...."
    	oShell.Exec ("\\Server01\epoAgent\FramePkg.exe /forceinstall /Silent /install=agent") 
    End If
    
    
    '***********************************************************************************************
    '***********************************************************************************************
    
    Function Checkstate 				'function to check if Epo agent is installed and running.
    
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_Service",,48)
    For Each objItem in colItems
    	If  objitem.displayname = "McAfee Framework Service" then
    		Wscript.Echo "Started: " & objItem.Started
    			If objitem.started = "False" Then
    				CheckState = "false"
    			Else 
    				Checkstate = "true"
    			end if	
    		Exit For 
    	End If
    Next
    End Function
    
    
    Function StartService				'fuction to start the service...
    
    On Error Resume next
    
    StrComputer = "."
    Set objWMIservice = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
    Set Colitems = ObjWMIservice.execquery ("Select * from win32_service",,48)
    For Each objitem In colItems
    			If  objitem.displayname = "McAfee Framework Service" then
    			Wscript.Echo "Started: " & objItem.Started
    				If objitem.started = "False" Then
    					objitem.StartService ("Mcafee Framework Service")
    				End If
    			Exit for
    			End If
    Next
    End Function
    Last edited by Dumber; 11th August 2009, 21:47.
    Marcel
    Technical Consultant
    Netherlands
    http://www.phetios.com
    http://blog.nessus.nl

    MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
    "No matter how secure, there is always the human factor."

    "Enjoy life today, tomorrow may never come."
    "If you're going through hell, keep going. ~Winston Churchill"

Working...
X