Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

check for cisco vpn connection...enabled or disabled

I have a CISCO Vpn anyconnect secure mobility client.
v 3.1.02040

Does any one know of a way in vba to check and see if a vpn connection is established or not ?


Thanks
fordraiders
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fordraiders

ASKER

Thanks !
als315, This is passing any test i give it.  Off or on vpn ?
nm, this worked for now.
Function IsVPNConnected()
   
   IsVPNConnected = False
   sComputer = "."

   Set oWMIService = GetObject("winmgmts:\\" _
    & sComputer & "\root\CIMV2")

   
   Set colItems = oWMIService.ExecQuery( _
    "SELECT * FROM Win32_NetworkAdapterConfiguration", , 48)

   
   For Each objItem In colItems

'Please check description of your VPN Connection by running command "ipconfig /all" on command-line.

    If (InStr(objItem.Description, "AnyConnect")) Then
     IsVPNConnected = objItem.IPEnabled
    End If

   Next
   

   If (IsVPNConnected) Then
    IsVPNConnected = MsgBox("I am Connected to VPN.")
   Else
    IsVPNConnected = MsgBox("I am Not Connected to VPN.")
   End If

End Function