DHCP to Static batch file

April 29, 2009 at 09:05:04
Specs: Windows XP
Hello, I am looking for a batch that will take a current IP address and turn it into static. I found one that has to be editted first and then run using the netsh command, but I need one that will automatically check the current IP address, pass it to a variable and then configure the TCP/IP properties from DHCP to static using the current IP address assigned by the DHCP server. Any help would be greatly appreciated. Thanks in advance.

See More: DHCP to Static batch file

Report •

April 29, 2009 at 09:41:52
Not a good idea unless you also disable the DHCP server. Manually allocating IP addresses within the scope of a DHCP server can lead to you having duplicate IP addresses.


Report •

April 29, 2009 at 09:48:45
Yes. DHCP will be disabled after the batch file runs. Just didn't want to reconfigure each PC manually.

Report •

April 29, 2009 at 10:49:13
You'll want to create a batchfile that utilizes the netsh command.


I'm going to add in a copy of a batchfile I use to change IP's on my PC. Ignore the part where you choose which NIC but you may find the rest useful if you need to actually configure static IP's on the target PC's. This will allow you to do it.

***Begin Batchfile***

::== chgIP.bat
@echo off
echo NIC to change IP on?
set /p NIC=
echo new IP ?
set /p IP=
echo new GW ?
set /p GW=

netsh int ip set add %NIC% static %IP% %GW% 1
::== end

***End Batchfile***

Report •

Related Solutions

April 29, 2009 at 11:13:41
Curt R,
I already have something similar to this, but I like yours better. Unfortunately not quite what I was looking for. Now, if there was a way to take the information stored in the "Ethernet adapter Local Area Connection" section of the ipconfig command, pass it on to the "Set /p IP=" & "Set /p GW=" sections of your batch file, that would be awesome.

Report •

April 29, 2009 at 13:05:40
Sadly, I can't help you with that. The above batchfile is about the limit of my batchfiling skills. If this were a UNIX or Linux box, I could make it happen easily in a script.

So what you're saying is, you want to take the IP as assigned by DHCP and make it static on each interface, correct?

There may be a way to do that. I highly recommend you contact a fellow named Mechanix2Go who hangs out on this site. Use the private message function on computing.net and contact him that way. He's the best batchfiler I've ever met and if anybody can help you with this, he would be the one I would bet on being able to do this, if it's possible.

Report •

April 29, 2009 at 13:11:17
Yes, that's exactly what I'm try to do. I will try your suggestion and send Mechanix2Go a message. Thanks.

Report •

Ask Question