View Single Post
  #3  
Old 02-14-2012, 12:43 PM
zementmischer zementmischer is offline
Member
 
Join Date: Apr 2011
Location: Europe
Posts: 43
Default

You can use the network command shell 'netsh.exe' for such tasks:
Code:
@ECHO OFF
ECHO Enter IP Address
SET /P ipaddr=
ECHO Enter Subnet Mask
SET /P subnet=
ECHO Enter Default gateway
SET /P gateway=
ECHO Enter Primary DNS
SET /P pridns=
ECHO Enter Secondary DNS
SET /P secdns=
netsh interface ip set address "Local Area Connection" static %ipaddr% %subnet% %gateway% 1
netsh interface ip set dns "Local Area Connection" static %pridns%
netsh interface ip add dns "Local Area Connection" %secdns% index=2
ipconfig /all
You can get the names of your ethernet adapters with 'ipconfig' or 'ipconfig /all'.
Just look for 'Ethernet adapter' or 'Wireless LAN adapter', eg.
Code:
ipconfig/all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : YourHostName
   ....

Wireless LAN adapter Wireless Network Connection:

   Connection-specific DNS Suffix  . : Home
   ....

Ethernet adapter Local Area Connection 1:

   Media State . . . . . . . . . . . : Media disconnected
   ....

Ethernet adapter Bluetooth Network Connection:

   Media State . . . . . . . . . . . : Media disconnected
   ....

Ethernet adapter Local Area Connection 2:

   Connection-specific DNS Suffix  . :
   ....
This example output contains 4 network interfaces: 'Wireless Network Connection', 'Local Area Connection 1', 'Bluetooth Network Connection' and 'Local Area Connection 2'
__________________
Real programmers don't comment their code.
If it was hard to write, it should be hard to read.

Last edited by zementmischer : 02-14-2012 at 01:01 PM.
Reply With Quote