Changing IP address

Hi,

I'm writing a program to change the IP address of a PC in Windows XP and NT.
I tried to manually change the IP address of a PC (using control panel)and there are 2 places in registry being changed.
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{Adapter... ID}\Parameters\Tcpip]
IPAddress="XXX"

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\Adapter... ID]
IPAddress="XXX"

do i need to change these 2 places ?
I understand that the main place to change is
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\Adapter... ID]IPAddress="XXX"

but do i need to change [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{Adapter... ID}\Parameters\Tcpip]IPAddress="XXX" ?
what is this registry for ?

Appreciate your advice , thanks in advance.

Regards,
CB
chekbanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

acl-puzzCommented:
why bother using registry for this use windows in-built commands to use in yours program

if u want to set up ip address via cmd in windows >>:—

netsh interface ip set address name=”Local Area Connection” static 192.168.0.1 255.255.255.0 192.168.0.1 1
the last 1 indicates the metric and it can be 2,3…

( Metric is the number of hops to the destination. Anything on the local LAN is one hop and each router crossed after that is an additional hop. The Metric is used to determine the best route)

if want to set up dns >>:–

1.netsh interface ip set dns “Local Area Connection” static 192.168.1.28  (THIS IS FOR primary dns server)

2.netsh interface ip add dns name=”Local Area Connection”  192.168.1.67 index=2 (THIS IS FOR secondary dns server)

if want to get ip via dhcp >>:–

netsh interface ip set address name=”Local Area Connection” dhcp

if u wanna have dns via dhcp >>:–

netsh interface ip set dns name=”Local Area Connection” dhcp


Cheers



0
chekbanAuthor Commented:
For some reason i need to change the IP in registry
0
B HCommented:
not sure how you'll get the adapter id, it's likely to be different between pc's

if you do it by the registry, you'll need to have a reboot after you set it, before it'll work
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

johnb6767Commented:
"For some reason i need to change the IP in registry "

why?
0
chekbanAuthor Commented:
Basically i just want to know what is this registry for
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{Adapter... ID}\Parameters\Tcpip]
IPAddress="XXX"

Anyone can help ?

0
B HCommented:
this is all about that key:
http://support.microsoft.com/kb/314053

but - you're not going to easily be able to parse the individual adapter id's from multiple machines via a script
0
chekbanAuthor Commented:
dear bryon,
i've seen that article before, that article only mentioned about
Tcpip\Parameters\Interfaces\ID for Adapter

and not
\CurrentControlSet\Services\{Adapter... ID}\Parameters\Tcpip]
0
B HCommented:
there are several places in the registry, as you've seen, where you can specify ip addresses.  services\adapter-id\parameters\tcpip tell the network card itself what to be.  some of the other values tell the stack itself what to be, others tell windows what to think it is

while looking for this for you, i came across a premade script that actually goes and finds out the adapter GUID for you, stores it in a variable, then pumps your settings back in.  a tiny bit of customization and this would do real well for you:

http://techsupt.winbatch.com/TS/T000001013F9.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
acl-puzzCommented:
"Basically i just want to know what is this registry for
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\{Adapter... ID}\Parameters\Tcpip]
IPAddress="XXX" "

This is for network interface  card you have in my case i have four adapter 1 is on board two virtual for vmware workstation and one is loopback and preference is given to on board NIC  

as you can see in pix those settings are from my 1st NIC(physical) and all comes after that

HtH


untitled.JPG
0
acl-puzzCommented:
and one more thing  i forgot to type is IPAddress is used for static ip address
0
chekbanAuthor Commented:
not the exact answer i'm looking for. but thanks for the effort
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
TCP/IP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.