Solved

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

Posted on 2016-09-18
  • Windows Networking
  • VBA
  • Microsoft Office
  • Microsoft Excel
  • VPN
  • +1
15
61 Views
Last Modified: 2016-10-16
Help, does anyone know how to get the vpn or Internet access in excel macro code and show it as a msgbox? - Jay
0
Comment
Question by:Jay Polo
  • 7
  • 5
  • 2
15 Comments
 
LVL 69

Expert Comment

by:Qlemo
ID: 41803947
I'm not clear what you want to achieve here. Could you elaborate more on what the purpose is exactly?
0
 

Author Comment

by:Jay Polo
ID: 41804528
 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
 
LVL 69

Expert Comment

by:Qlemo
ID: 41804648
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:Jay Polo
ID: 41804673
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
 

Author Comment

by:Jay Polo
ID: 41804677
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
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 250 total points (awarded by participants)
ID: 41804728
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
 

Author Comment

by:Jay Polo
ID: 41804732
is this MS Excel VBA Macro?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41805067
No, it is a cmd.exe batch file (.cmd or .bat).
0
 

Author Comment

by:Jay Polo
ID: 41805248
Aww. I appreciate your efforts. But I would need something Excel macro related language. :(
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 41805266
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
 

Author Comment

by:Jay Polo
ID: 41805296
I'll try that one if it's ok? hopefully that would complete this file.
0
 

Author Comment

by:Jay Polo
ID: 41809105
up :(
0
 
LVL 40

Accepted Solution

by:
als315 earned 250 total points (awarded by participants)
ID: 41818624
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
 
LVL 40

Expert Comment

by:als315
ID: 41845495
Idea in ipconfig, parsing in vba
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

An article on effective troubleshooting
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

856 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