Skip to content

Instantly share code, notes, and snippets.

@pastareal
Created August 29, 2024 13:22
Show Gist options
  • Save pastareal/2295e4bab6e1d635f65aa5d0977b1f37 to your computer and use it in GitHub Desktop.
Save pastareal/2295e4bab6e1d635f65aa5d0977b1f37 to your computer and use it in GitHub Desktop.
get IP address and computer name of host using VBS
dim NIC1, Nic, StrIP, CompName
Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Nic in NIC1
if Nic.IPEnabled then
StrIP = Nic.IPAddress(0)
Set WshNetwork = WScript.CreateObject("WScript.Network")
CompName= WshNetwork.Computername
MsgBox "IP Address: "&StrIP & vbNewLine _
& "Computer Name: "&CompName,4160,"IP Address and Computer Name"
wscript.quit
End if
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment