Created
August 29, 2024 13:22
-
-
Save pastareal/2295e4bab6e1d635f65aa5d0977b1f37 to your computer and use it in GitHub Desktop.
get IP address and computer name of host using VBS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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