Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Grabbing IP address then setting to 2nd nic

Reply
 
Old 06-19-2008   #1 (permalink)
drunkeninja


 
 

Grabbing IP address then setting to 2nd nic

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.

My System SpecsSystem Spec
Old 06-19-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: Grabbing IP address then setting to 2nd nic


"drunkeninja" <shaolindriver@xxxxxx> wrote in message
news:767ff9c7-53af-4412-986b-868e09f80e08@xxxxxx
Quote:

>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.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Setting-up address folders in Windows Mail? Vista mail
Vista assigns 0.0.0.0 IP address when setting up static IP Vista networking & sharing
setting for replies: receiver address - not default address Vista mail
Setting up Hotmail address Vista General
MAC address setting on Vista Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46