eleve Posted January 15, 2008 Posted January 15, 2008 (edited) Hello, I'll try to explain to you my matter. I'm in BTS Informatique de Gestion (computing in simpler), and one project is to create a windows which can be installed without any user. My matter is : who increment the name of the PC with only the IP adress. Ex: If the PC have the IP : 192.168.0.5 I wanna the name PC-TEST 5, if the PC have the IP : 192.168.0.14, I wanna the name PC-TEST 14, ... . It's possible? With a script, with WPI, with nlite? Edited January 15, 2008 by eleve
gunsmokingman Posted January 15, 2008 Posted January 15, 2008 (edited) Hello, I'll try to explain to you my matter. I'm in BTS Informatique de Gestion (computing in simpler), and one project is to create a windows which can be installed without any user. My matter is : who increment the name of the PC with only the IP adress. Ex: If the PC have the IP : 192.168.0.5 I wanna the name PC-TEST 5, if the PC have the IP : 192.168.0.14, I wanna the name PC-TEST 14, ... . It's possible? With a script, with WPI, with nlite?Using your 2 example plus I added a Local Address to confirmed it working.How this script works is as follows1:\ It starts with a Array that holds all your ip address2:\ It Loops threw the Array to ping the computers3:\ If the ping returns false nothing happens it continues threw the Array4:\ If the ping returns true it the uses a Case Select to see what ip respondedand sets the varible called NameComputer.I have not added any scripting to change the name of the computer. You will haveto add the ip`s to the Array Called Computer.This script will only work ON XP and UPSave As Ping.vbs Option Explicit Dim ArrComputer, Computer, NameComputer, Pings, Status, strComputer, Wmi strComputer = "."'-> Array To Hold IP Addresses Computer = Array( _ "192.168.0.5",_ "192.168.0.14",_ "127.0.0.1")'-> Connect To WMI Set Wmi = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")'-> Loop To Go Threw Computer Array For Each ArrComputer In Computer'-> WMI Class We Used Using Array Computer Set Pings = Wmi.ExecQuery("Select * From Win32_PingStatus where Address = '" & ArrComputer & "'")'-> Ping Computer In The Array For Each Status in Pings If IsNull(Status.StatusCode) or Status.StatusCode<>0 Then WScript.Echo "Computer did not respond." Exit For Else'-> Where We Select Which IP Returned True Select Case ArrComputer Case "192.168.0.5" NameComputer = "PC-TEST 5" Case "192.168.0.14" NameComputer = "PC-TEST 14" Case "127.0.0.1" NameComputer = "My Computer Test" End Select'-> Add A A Script Here To Change The Computer Name To NameComputer Wscript.Echo "Computer responded." & vbtab & NameComputer End If Next Next Edited January 15, 2008 by gunsmokingman
IcemanND Posted January 15, 2008 Posted January 15, 2008 If all you want is the last octet of the IP address, which will limit you to 256 machines you could do this very simply, as gunsmokingman showed though it could be even easier. If you are going to be doing this in a larger organization and you have DHCP and all the machines are registered so that the machine name is associated with the MAC address of the machine you could poll DNS and rename the machine according to the registered info.
eleve Posted January 18, 2008 Author Posted January 18, 2008 thank you, I'll try soon, and I'll say you the result after.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now