Computing.Net > Forums > Programming > Batch Script Help

Batch Script Help

Reply to Message Icon

Original Message
Name: techhelp00
Date: March 15, 2007 at 14:55:00 Pacific
Subject: Batch Script Help
OS: Windows
CPU/Ram: 2.6/1GB
Model/Manufacturer: Dell
Comment:

I need some help writing a batch script to do the following:

First check to see if Network connection is on DHCP. If it is, exit. If not, change the DNS Server IP address to specified static IPs.

This is what I have for changing the IP...I just don't know how to check for DHCP and exit if it is or continue if it is not DHCP.


netsh interface ip set dns name="Local Area Connection" source=static addr=192.168.1.1 register=PRIMARY
netsh interface ip add dns name="Local Area Connection" addr=192.168.1.2 index=2

netsh interface ip set dns name="Local Area Connection 2" source=static addr=192.168.1.1 register=PRIMARY
netsh interface ip add dns name="Local Area Connection 2" addr=192.168.1.2 index=2


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: March 15, 2007 at 16:42:39 Pacific
Reply: (edit)

Like the forum guidelines say, the EXACT OS will help.

This can be used in NT/XP:

ipconfig /all|find "DHCP" |find "Yes"
if errorlevel 1 goto :setIP
goto :eof
:setIP
:: here's where you do you thing


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch Script Help

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge