Solved

Script to setup wireless connection.

Posted on 2007-11-29
5
3,225 Views
Last Modified: 2010-04-21
I want to script the setup for an XP wireless connection. One script will set the interface to DHCP. The other will setup discrete IP information on the same interface.
0
Comment
Question by:HilltownHealthCenter
  • 3
  • 2
5 Comments
 
LVL 26

Accepted Solution

by:
Pber earned 250 total points
ID: 20377798
First you'll need to get thewireless interface name.  to do that run this from the command prompt:

Netsh interface ip dump

You'll get an output like this:

# ----------------------------------
# Interface IP Configuration
# ----------------------------------
pushd interface ip


# Interface IP Configuration for "Wireless Connection"

set address name="Wireless Connection" source=dhcp
set dns name="Wireless Connection" source=dhcp register=PRIMARY
set wins name="Wireless Connection" source=dhcp


popd
# End of interface IP configuration

The value you are looking for is name="something"
You want the value within the quotes.

Once you have that, replace the "something" with the actual name of your Wireless interface.

Create two batch files and as follows (change the IP, Mask, gateway, DNS and WINS servers to match your network settings)...

Call this batch "Wireless_DHCP.BAT"
@echo off
REM Wireless_DHCP.BAT
Echo Setting Wireless to DHCP
netsh interface ip set address name="Wireless Connection" source=dhcp
netsh interface ip set dns name="Wireless Connection" source=dhcp register=PRIMARY
netsh interface ip set wins name="Wireless Connection" source=dhcp
REM End of Wireless_DHCP.BAT

Call this batch "Wireless_Static.BAT"

@echo off
REM Wireless_Static.BAT
Echo Setting Wireless to Static

netsh interface ip set address name="Wireless Connection" source=static addr=192.168.1.50 mask=255.255.255.0
netsh interface ip set address name="Wireless Connection" gateway=192.168.1.1 gwmetric=0
netsh interface ip set dns name="Wireless Connection" source=static addr=192.168.1.200 register=PRIMARY
netsh interface ip add dns name="Wireless Connection" addr=192.168.1.201 index=2
netsh interface ip set wins name="Wireless Connection" source=static addr=192.168.1.202
netsh interface ip add wins name="Wireless Connection" addr=192.168.1.203 index=2
REM End of Wireless_Static.BAT

Just run the applicable batch file to switch between settings.
0
 
LVL 26

Expert Comment

by:Pber
ID: 20377816
One thing else,

Replace "Wireless Connection" in both batch files to the value of name="something" for the wireless connection for the output of the command: netsh interface ip dump.
0
 

Author Comment

by:HilltownHealthCenter
ID: 20383818
Looks like exactly what I am looking for!    I am a bit fuzzy about what some of  the entries mean.

If I were setting the interface address to . . .50 (as in your example?), then what do the following do?:

netsh interface ip set dns name="Wireless Connection" source=static addr=192.168.1.200 register=PRIMARY
netsh interface ip add dns name="Wireless Connection" addr=192.168.1.201 index=2
netsh interface ip set wins name="Wireless Connection" source=static addr=192.168.1.202
netsh interface ip add wins name="Wireless Connection" addr=192.168.1.203 index=2
0
 

Author Closing Comment

by:HilltownHealthCenter
ID: 31411804
I went to the netsh site, to figure out the syntax and meaning. Works like a charm. Thanks Pber!
Man I love this site!
0
 
LVL 26

Expert Comment

by:Pber
ID: 20404853
Sorry for note getting back to you.


These settings set your DNS records:
netsh interface ip set dns name="Wireless Connection" source=static addr=192.168.1.200 register=PRIMARY
netsh interface ip add dns name="Wireless Connection" addr=192.168.1.201 index=2

...the index=2 sets the secondary server.  If you only have one dns server, the second entry can be deleted.
If you don't have any dns or wins servers, the respective entries are all optional.

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wireless Access Points, Network 5 51
preview video of network plus 2 67
HP PC Hardware Diagnostics UEFI 11 79
shortcuts on desktops 14 52
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
Need WiFi? Often, there are perfectly good networks that don't have WiFi capability - and there's a need to add it.  - Perhaps you have an Ethernet port into a network but no WiFi nearby. - Perhaps you have a powerline extender and no WiFi at the…
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now