Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ipaddress display 1

Status
Not open for further replies.
Feb 1, 2005
144
US
Hi is it possible to display the ip address of a machine under a icon like the my computer icon using vbscript?

 
Code:
'==========================================================================
'
' NAME: Rename MyComputer icon with IP Address.
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.TheSpidersParlor.com[/URL]
' COPYWRITE (c) 2005 All Rights Reserved
' DATE  : 8/24/2005
'
' COMMENT: Determines current DHCP IP Address of computer
'          Assumes that there is only ONE active NIC.  
'          then sets that as the name for My Computer
'==========================================================================
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
".\root\default:StdRegProv")

Set WSHShell = CreateObject("Wscript.Shell")
strKeyPath = "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys

    DHCPAddress = WSHShell.RegRead("HKLM\" & strKeyPath & subkey & "\DhcpIPAddress")
    If DHCPAddress <> "0.0.0.0" And Left(DHCPAddress,3) <> "169" Then
        ActiveDHCPIPAddress = DHCPAddress    
    End If
Next



'This will rename the My Computer icon with the computer name
MCPath = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
WSHShell.RegWrite MCPath & "\", ActiveDHCPIPAddress, "REG_SZ"

I hope you find this post helpful.

Regards,

Mark
 
Nice one. Also found a way to display computer name or user..Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top