Solved

Script to setup wireless connection.

Posted on 2007-11-29
5
3,230 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today sees the launch of a new case study, focusing on BYOD technologies we have been working with for some time now.  But with the advent of 802.11ac wireless technologies and the story behind our landmark developments, we would like to share this …
In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

860 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