?
Solved

check for cisco vpn connection...enabled or disabled

Posted on 2013-12-05
4
Medium Priority
?
666 Views
Last Modified: 2014-01-09
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
0
Comment
Question by:fordraiders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 39700170
You can ping far side of vpn connection. Details of WMI Win32_PingStatus you can find here:
http://msdn.microsoft.com/library/aa394350(v=VS.85).aspx
Vba version:
Sub test()
If Ping("192.168.2.2") Then
    MsgBox "Passed", vbOKOnly
Else
    MsgBox "Failed", vbOKOnly
End If
End Sub
Public Function Ping(ByVal ComputerIP As String) As Boolean
    'You can use also name of computer
    ' Return TRUE, if pin was successful
   Dim oPingResult As Variant
    For Each oPingResult In GetObject("winmgmts://./root/cimv2").ExecQuery _
        ("SELECT * FROM Win32_PingStatus WHERE Address = '" & ComputerName & "'")
        If IsObject(oPingResult) Then
            If oPingResult.StatusCode = 0 Then
                Ping = True
                'Debug.Print "ResponseTime", oPingResult.ResponseTime 'You can also return ping time
               Exit Function
            End If
        End If
    Next
End Function

Open in new window

0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39712241
Thanks !
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39769586
als315, This is passing any test i give it.  Off or on vpn ?
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39769645
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question