0

With the help of an awesome user here Theo...we were able to make a message box come up with the following information --> Username: user Computer Name: Computer1 Wired IP: X.X.X.X Wireless IP: X.X.X.X Which this has been working out great. But now with current conditions a lot of our staff are using VPN and I would like to have this box also show VPN IP as well, but only if they are connected to the VPN. Is this possible? Any help would be greatly appreciated!

Option Explicit

On Error Resume Next
Dim WSH, WshNtwk, objWMIService, IPAdapterSet, IPConfig, IPConfigSet, IPConf
Dim strMsg, strComputer, infoStr, FinalIP

Set WSH = WSCript.CreateObject("WScript.Shell")
Set WshNtwk = WScript.CreateObject("WScript.Network")
strMsg = ""
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set IPAdapterSet = objWMIService.ExecQuery("Select AdapterTypeID, NetConnectionID, MACAddress from Win32_NetworkAdapter")

' values for AdapterTypeID: https://learn.microsoft.com/en-us/windows/desktop/cimwin32prov/win32-networkadapter
For Each IPConfig in IPAdapterSet
    Set IPConfigSet = objWMIService.ExecQuery("Select IPEnabled, Description, Caption, IPAddress, MACAddress from Win32_NetworkAdapterConfiguration where IPEnabled='True' AND MACAddress = '" & IPConfig.MACAddress & "'")
    For Each IPConf in IPConfigSet
        If Not IsNull(IPConf.IPAddress) Then
            If Instr(1, IPConfig.NetConnectionID, "Wireless", vbTextCompare) > 0 Then
                strMsg = strMsg & "- Wireless IP: " & vbTab
            Else
                strMsg = strMsg & "- Wired IP:    " & vbTab
            End If

            strMsg = strMsg & Join(IPConf.IPAddress, ", ") & vbCrLf
            strMsg = strMsg & "- MAC Address: " & vbTab & IPConfig.MACAddress & vbCrLf & vbCrLf
        End If
    Next
Next

''WScript.Echo strMsg
infoStr = "Please provide the following information to the IT Technician." & vbCrLf & vbCrLf & _
"Username :" & vbTab & WshNtwk.UserName & vbCrLf & _
"Computer Name :" & vbTab & Ucase(WshNtwk.ComputerName) & vbCrLf & _
"IP Addresses:" & vbCrLf & strMsg
'"Domain:" & WshNtwk.UserDomain
' Display the IP address and computer name in user-friendly message box
MsgBox infoStr, 64, "Some Title"
'"Computer Name:" & vbTab & Ucase(WshNtwk.ComputerName) & vbCrLf & "IP Address:" & vbTab & FinalIP, vbOkOnly , "SCCCMHA PC Information"
On Error Goto 0

'cleanup
Set IPConf = Nothing
Set IPConfig = Nothing
Set objWMIService = Nothing
Set IPAdapterSet = Nothing
Set WSH = Nothing
Set WshNtwk = Nothing

WScript.Quit
  • So have you tried modifying the script in a bid to understand it, or even research some of the code being used or you just here for more free code? I would have hoped you had attempted to modify this script before coming back to [SO] and posting for someone to do it for you. – user692942 Apr 14 '20 at 14:46
  • Does this answer your question? [Get server IP of PPP VPN in Windows using VBScript or CMD](https://stackoverflow.com/questions/1699456/get-server-ip-of-ppp-vpn-in-windows-using-vbscript-or-cmd) – user692942 Apr 14 '20 at 14:49

0 Answers0