"drunkeninja" <shaolindriver@xxxxxx> wrote in message
>I am trying to combine code which grabs the ip address of a server
> then set it to a 2nd NIC via the netsh command
> netsh interface ip set address "Local Area Connection 2" static IP
> is it possible to set this as a variable obtained from code in the 1st
> 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"
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.