Welcome ! Login
Original Message
Forum MS Windows 
Topic DHCP / Static IP Script 
Author Palpatine 
Date Created 7/19/2006 10:33:41 AM 
Message Here is a BAT script to switch clients from DHCP to a Static IP or Static to DHCP. The script will prompt you for a choice.
Copy and paste this script to a text file and rename it to YOUFILENAME.bat .


--------------START COPY PASTE OF SCRIPT--------------

@echo off

setlocal

set OK=N







:again

set /p choice=Please enter 1[SF Office], 2[DHCP] or END ??

if /i [%choice%]==[END] endlocal&goto end

if [%choice%]==[] goto again

if [%choice%]==[1] goto 1

if [%choice%]==[2] goto 2

set /p xxx=wrong entry, press any key to exit.

endlocal

goto end







:1

echo Setting IP to Static IP.....

netsh interface ip set address name="Local Area Connection" source=static addr=x.x.x.x mask=255.255.255.0

netsh interface ip set address name="Local Area Connection" gateway=x.x.x.x gwmetric=0

netsh interface ip set dns name="Local Area Connection" source=static addr=x.x.x.x register=BOTH

netsh interface ip add dns name="Local Area Connection" addr=x.x.x.x index=2

netsh interface ip set wins name="Local Area Connection" source=static addr=x.x.x.x





set /p see=IP changed successfully to Static IP Press [9] To see new Settings Press [Enter] to exit...

if [%see%]==[9] goto show

echo Ending IP Configuration

goto end









:2

echo Setting IP to DHCP.....

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

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









set /p see=IP changed successfully to DHCP Press [9] To see new Settings Press [Enter] to exit...

if [%see%]==[9] goto show

echo Ending IP Configuration

goto end







:show

ipconfig







:end

@echo on


--------------END COPY PASTE OF SCRIPT---------------- 
      
Responses
No records
Home Recipes Links Blog Forums Join Us