'GetIPaddr.vbs - Check the IP address you are currently 'connected to the Internet with (or LAN IP). 'LabAdmin - Computer Center ' rev-2 15 May 2007 by KX ' rev 25 April 2007 ' Now works with Windows NT, 2K, XP Option Explicit Dim newName newName = "_" + GetLastIPNo+"_" RenameComputer(newName) Function RenameComputer(Name) Dim strComputer Dim objWMIService, colComputers, objComputer strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colComputers = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer in colComputers err = objComputer.Rename(Name) Next End Function Function GetLastIPNo() Dim ws : Set ws = CreateObject("WScript.Shell") Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") 'Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "\ip.txt" Dim TmpFile : TmpFile = "ip.txt" Dim ThisLine, IP, IPArr If ws.Environment("SYSTEM")("OS") = "" Then ws.run "winipcfg /batch " & TmpFile, 0, True Else ws.run "%comspec% /c ipconfig /all > " & TmpFile, 0, True End If With fso.GetFile(TmpFile).OpenAsTextStream Do While NOT .AtEndOfStream ThisLine = .ReadLine If InStr(ThisLine, "Physical Address") <> 0 Then IP = Mid(ThisLine, InStr(ThisLine, ":") + 2) Loop .Close End With 'WinXP (NT? 2K?) leaves a carriage return at the end of line If IP <> "" Then If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1) End If IPArr = Split(IP,"-") GetLastIPNo = IPArr(0)+IPArr(1)+IPArr(2)+IPArr(3)+IPArr(4)+IPArr(5) fso.GetFile(TmpFile).Delete Set fso = Nothing Set ws = Nothing End Function