Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Script to setup wireless connection.

Posted on 2007-11-29
5
Medium Priority
?
3,244 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 1000 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

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

Question has a verified solution.

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

Using in-flight Wi-Fi when you travel? Business travelers beware! In-flight Wi-Fi networks could rip the door right off your digital privacy portal. That’s no joke either, as it might also provide a convenient entrance for bad threat actors.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
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…
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…

564 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