![]() |
Change IP LogIn Script Help *please*;)
Calling the Power of Scoobynet
I need to change the static IP's of about 150 pcs on our network, and the associated Hosts file - something like this:- m\c W1A gets IP 10.2.1.1 m\c W1B gets IP 10.2.1.2 m\c W1C gets IP 10.2.1.3 etc m\c W2A gets IP 10.2.2.1 m\c W2B gets IP 10.2.2.2 m\c W2C gets IP 10.2.2.3 I know you can use NETSH with W2k & XP - see example:- :: Set the IP address. netsh interface ip set address "Local Area Connection" static 192.168.1.10 255.255.255.0 192.168.1.1 1 netsh interface ip set dns "Local Area Connection" static 192.168.1.2 but i need it to 'look up' the m\c name and choose the correct IP from the list, using a TXT file or similar. HELP! I could have one script per block i.e W1's W2's W3's I reckon changing the HOSTS file should be easy such as: if exists "C:\windows\drivers\system32\drivers\hosts copy \\server\hosts C:\windows\drivers\system32\drivers\hosts" if exists "C:\winnt\drivers\system32\drivers\hosts copy \\server\hosts C:\winnt\drivers\system32\drivers\hosts" all the PC's are mainly W2k or XP (occasional NT but I can do these few manually if needed) using NT4 domain server Actually could probably use %root% on the above example to save having to have two lines And don't even mention DHCP - i know, i know - but my IT director doesnt:rolleyes: SO anybody got any help with this script - beg beg:D |
|
Thanks for the swift post -
YHM :) |
Code:
' Read Machine Names from file specified below in the format: machinename,Ipaddress with one machine per line |
Blimey - Thanks a lot, it looks fabulous - I won't try and fool you into knowing what the hell it does - its mostly double dutch to me!
How do I format my TXT file? W1A,10.2.0.1,W1B,10.2.0.2,W1C,10.2.0.3....etc or another way? and do I need to run it for each block, W1's W2's or does it do it in one big file? Thanks again! |
machinea,10.0.0.1
computera,10.0.0.2 fred,192.168.0.1 run it for each block??? eh? |
yep - tried it on my PC this afternoon and it works great - thanks! Just need to build the full TXT file & set the Login Script for all the users now.
I tried to add the pri DNS setting in to the script but it didnt work:- I put in:- define the Dns str variable at the top of the script a la Gateway & subnet strDns = Array("195.183.89.230") then near the bottom after the errGateways line: errDns = objNetAdapter.SetDns(strDns, strDnsmetric) I'm guessing its just a syntax problem as the DNS has a primary & secondary value - or am I going about this the wrong way..... Thanks again for all your help - you've saved me some serious shoe leather here! |
dns doesnt have a metric for a start.
David |
try....
Code:
' Read Machine Names from file specified below in the format: machinename,Ipaddress with one machine per line |
All times are GMT +1. The time now is 10:00 AM. |
© 2024 MH Sub I, LLC dba Internet Brands