"drunkeninja" <shaolindriver@xxxxxx> wrote in message
news:767ff9c7-53af-4412-986b-868e09f80e08@xxxxxx
>I am trying to combine code which grabs the ip address of a server
> from
> http://groups.google.com/group/micro...751466d5406803
>
> then set it to a 2nd NIC via the netsh command
>
> netsh interface ip set address "Local Area Connection 2" static IP
> ADDRESS
>
> is it possible to set this as a variable obtained from code in the 1st
> part???
>
> Also have been trying to use the the netsh command for only the
> ipaddress without wiping the rest of the details ie subnet/default
> gateway/dns etc. Since netsh.exe is a console command, it would simplify things
considerably if you used a batch file to extract and set your
IP address instead of shelling out of a VB Script. The following
code will do it:
1. @echo off
2. net start | find /i "Routing and Remote Access" > nul && goto Netsh
3. sc config "RemoteAccess" start= demand
4. net start "RemoteAccess"
5.
6. :Netsh
7. for /F %%a in ('netsh interface ip show ipaddress ^| find /i "wireless"')
do set IP=%%a
8. echo IP=%IP%
You must replace the word "wireless" with a non-ambiguous word
of your own NIC as shown in the Interface column of the command
netsh interface ip show ipaddress
Be careful with Line 3 - the space following the = is critical.