Get VPN or Internet Access as a MsgBox - Excel Macro Code

Help, does anyone know how to get the vpn or Internet access in excel macro code and show it as a msgbox? - Jay
Jay PoloAsked:
Who is Participating?
 
als315Connect With a Mentor Commented:
You can use this function to get status of named connection (no difference - vpn or other):
Public Function vpn_lookup(vpn_name As String) As String
'vpn_name - name of connection
Dim Sh As Object
Dim ex As Object
Dim cmd As String
Dim l As Integer
cmd = "ipconfig /all"
vpn_lookup = "not connected"
Set Sh = CreateObject("WScript.Shell")
Set ex = Sh.Exec(cmd)
ex.StdIn.Close
cmd = ex.StdOut.ReadAll
If InStr(1, cmd, vpn_name) > 0 Then vpn_lookup = "connected"
End Function

Open in new window

Chk_vpn.xlsm
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
I'm not clear what you want to achieve here. Could you elaborate more on what the purpose is exactly?
0
 
Jay PoloAuthor Commented:
 Sub ShowMeDetails ()

MsgBox Environ("COMPUTERNAME")
MsgBox Environ("USERPROFILE")
MsgBox Environ("USERDOMAIN")

End Sub 

Open in new window


I need to show as a MsgBox where the user has logged to (see picture, sample MsgBox ("VPN"=group.net).vpn connection
0
Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
And what if connected with LAN, WiFi and VPN? What to choose to display? And what is the purpose - or, how does it matter at all?
0
 
Jay PoloAuthor Commented:
And what if connected with LAN, WiFi and VPN? yes, if needed. All I need is to get where the user is connected (eg: group.net and would should as a MsgBox)

What to choose to display? just a MsgBox

And what is the purpose - or, how does it matter at all? we are checking how many users are using the VPN, connected at school, at home, or in the office.
0
 
Jay PoloAuthor Commented:
Sub ShowMeDetails ()

MsgBox Environ("COMPUTERNAME")
MsgBox Environ("USERPROFILE")
MsgBox Environ("USERDOMAIN")
MsgBox ("VPN = Internet Access") 'I need this code to run my file

End Sub

Open in new window

0
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
Usually you generate a single (text) report file for that purpose, containing above environment variables and the result of ipconfig /all in a batch file:
@echo off
(
  set computername
  set userprofile
  set userdomain
  ipconfig /all
) > %temp%\diag.txt

Open in new window

Create that batch file, run it with the .Shell method, and then e.g. read in the text file created to display, or open it with notepad.
0
 
Jay PoloAuthor Commented:
is this MS Excel VBA Macro?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
No, it is a cmd.exe batch file (.cmd or .bat).
0
 
Jay PoloAuthor Commented:
Aww. I appreciate your efforts. But I would need something Excel macro related language. :(
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You know your way to output stuff results in "endless" message boxes popping up each with a single information? Not user-friendly ...
We certainly can provide code to generate the batch file, run it, and display the results from VBA, but I'm not sure you should want to do that ...
0
 
Jay PoloAuthor Commented:
I'll try that one if it's ok? hopefully that would complete this file.
0
 
Jay PoloAuthor Commented:
up :(
0
 
als315Commented:
Idea in ipconfig, parsing in vba
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.