移动WLAN测试

来源:互联网 发布:淘宝分享送红包设置 编辑:程序博客网 时间:2024/04/28 21:02

WLAN测试经常需要扫频,学生宿舍一般每层都有6、7个AP,一个个的关联很是麻烦,拿着笔记本又没有鼠标,如何快速的关联“CMCC-EDU”或者“ChinaNet”呢!经过探究,我就觉得如果有快捷键就好了,可是电脑上并没有快捷键啊,有的也最多是禁用无线网卡,还有开启网卡。以前我那台Thinkpad是有这个功能的,可以快速开启和关闭所有网络,包括蓝牙。可是我现在换成了一台HP了啊,这台老爷机,开关无线网卡的键都快报废了。后来我从网上查找,发现了DevCon,DevCon 命令行实用工具可替代设备管理器。我就从微软官网下载了,地址为:http://support.microsoft.com/kb/311272/zh-cn;下载后需要解压缩,然后放到system32目录下,就可以在命令控制台使用这个命令了。在这里需要特别注意的一点是,在Windows7系统下需要用有管理员权限的CMD,这样才能调试,查看帮助文档。命令很是简单,在CMD中输入“devcon ?”,可以查到以下的命令:

D:\Windows\system32>devcon ?
Device Console Help:
devcon [-r] [-m:\\<machine>] <command> [<arg>...]
-r if specified will reboot machine after command is complete, if needed.
<machine> is name of target machine.
<command> is command to perform (see below).
<arg>... is one or more arguments if required by command.
For help on a specific command, type: devcon help <command>
classfilter          Allows modification of class filters.
classes              List all device setup classes.
disable              Disable devices that match the specific hardware or instance ID.
driverfiles          List driver files installed for devices.
drivernodes          Lists all the driver nodes of devices.
enable               Enable devices that match the specific hardware or instance ID.
find                 Find devices that match the specific hardware or instance ID.
findall              Find devices including those that are not present.
help                 Display this information.
hwids                Lists hardware ID's of devices.
install              Manually install a device.
listclass            List all devices for a setup class.
reboot               Reboot local machine.
remove               Remove devices that match the specific hardware or instance ID.
rescan               Scan for new hardware.
resources            Lists hardware resources of devices.
restart              Restart devices that match the specific hardware or instance ID.
sethwid              Modify Hardware ID's of listed root-enumerated devices.
stack                Lists expected driver stack of devices.
status               List running status of devices.
update               Manually update a device.
updateni             Manually update a device (non interactive).


只要使用其中的 “restart” 就行了啊。

第一步是查看无线网卡的硬件ID,还是从设备管理器中查看方便,我的是“Intel(R) WiFI Link 5100 AGN”网卡,硬件ID为:“DEV_4237”见下图


第二步就是写个批处理文档,代码也是相当简单,如下

devcon restart *DEV_4237* //重新启动此PCI设备

然后,将其保存为“重新启动无线网卡.bat”

为文件建立快捷方式,


为快捷方式建个快捷键,


这样就搞定了,只要按“Ctrl + F1”这个快捷键就能重启无线网卡了。

无线连接中,勾选“当此网络在范围内时自动连接(M)”,

这样只要重启无线网卡,就能自动关联你想要的SSID了。


后来琢磨了两天,发现这方法并不是很好,因为扫频是需要变化SSID的,一会儿CMCC-EDU,一会儿又是ChinaNet的,这样就需要两个人配合扫频了,如果是一个人,该怎么办呢!于是我又打起了无线网卡配置文件的注意了。同样还是在CMD命令控制台中查看,这次使用的是“netsh”命令。

1. 其帮助如下:

D:\Windows\system32>netsh ?

用法: netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]UserName] [-p Password | *]
             [Command | -f ScriptFile]

下列指令有效:

此上下文中的命令:
?              - 显示命令列表。
add            - 在项目列表上添加一个配置项目。
advfirewall    - 更改到 `netsh advfirewall' 上下文。
branchcache    - 更改到 `netsh branchcache' 上下文。
bridge         - 更改到 `netsh bridge' 上下文。
delete         - 在项目列表上删除一个配置项目。
dhcpclient     - 更改到 `netsh dhcpclient' 上下文。
dnsclient      - 更改到 `netsh dnsclient' 上下文。
dump           - 显示一个配置脚本。
exec           - 运行一个脚本文件。
firewall       - 更改到 `netsh firewall' 上下文。
help           - 显示命令列表。
http           - 更改到 `netsh http' 上下文。
interface      - 更改到 `netsh interface' 上下文。
ipsec          - 更改到 `netsh ipsec' 上下文。
lan            - 更改到 `netsh lan' 上下文。
mbn            - 更改到 `netsh mbn' 上下文。
namespace      - 更改到 `netsh namespace' 上下文。
nap            - 更改到 `netsh nap' 上下文。
netio          - 更改到 `netsh netio' 上下文。
p2p            - 更改到 `netsh p2p' 上下文。
ras            - 更改到 `netsh ras' 上下文。
rpc            - 更改到 `netsh rpc' 上下文。
set            - 更新配置设置。
show           - 显示信息。
trace          - 更改到 `netsh trace' 上下文。
wcn            - 更改到 `netsh wcn' 上下文。
wfp            - 更改到 `netsh wfp' 上下文。
winhttp        - 更改到 `netsh winhttp' 上下文。
winsock        - 更改到 `netsh winsock' 上下文。
wlan           - 更改到 `netsh wlan' 上下文。

下列的子上下文可用:
 advfirewall branchcache bridge dhcpclient dnsclient firewall http interface ipsec lan mbn namespace nap netio p2p ras rpc trace wcn wfp winhttp winsock wlan

若需要命令的更多帮助信息,请键入命令,接着是空格,
后面跟 ?。




2. 只要使用“wlan”参数就可以了啊!其帮助文档如下:

D:\Windows\system32>netsh wlan ?

下列指令有效:

此上下文中的命令:
?              - 显示命令列表。
add            - 在一个表格中添加一个配置项。
connect        - 连接到无线网络。
delete         - 从一个表格中删除一个配置项。
disconnect     - 从无线网络断开。
dump           - 显示一个配置脚本。
export         - 将 WLAN 配置文件保存为 XML 文件。
help           - 显示命令列表。
refresh        - 刷新承载网络设置。
reportissues   - 生成 WLAN 智能跟踪报告。
set            - 设置配置信息。
show           - 显示信息。
start          - 启动承载网络。
stop           - 停止承载网络。

若需要命令的更多帮助信息,请键入命令,接着是空格,
后面跟 ?。



3. 接下来看看,“connect”后要写哪些参数,

D:\Windows\system32>netsh wlan connect ?

用法:  connect [name=]<string> [[ssid=]<string>] [[interface=]<string>]

参数:

    标记            值
    ssid          - 无线网络的 SSID。
    name          - 连接尝试所使用的配置文件的名称。
    interface     - 尝试连接的接口名称。

注释:

    连接到由使用指定配置文件的 ssid 给定的无线网络。从指定接口试图连接,除非
    系统仅有一个可用的接口,在这种情况下,该接口参数可省略。

    参数 profile name 是必需的,而 ssid 是可选的。如果只有一个 SSID 存在,那么该
    SSID 用于连接。如果在配置文件中有多个 SSID,那么参数 ssid 是必需的。

    如果在系统上有两个或多个接口可用,参数 interface 是必需的。当指定 interface
    时,该 interface 不能是通配名称。

    如果指定接口已经连接到无线网络时,该命令将首先从当前连接的网络断开,
    然后尝试连接到新的网络。如果在该命令中两个网络相同,该命令仅简单返回成功。

示例:

    connect name=Profile1 ssid=SSID1
    connect name=Profile2 ssid=SSID2 interface="Wireless Network Connection"



4.  接下来查看无线网络接口

D:\Windows\system32>netsh wlan show interfaces

系统上有 1 个接口:

    名称                   : 无线网络连接
    描述                   : Intel(R) WiFi Link 5100 AGN
    GUID                   : 39f69c33-eb42-4cc0-9865-b8c482a0d73c
    物理地址               : 00:26:c6:d7:4a:5e
    状态                   : 已连接
    SSID                   : CMCC
    BSSID                  : f8:d1:11:ec:73:14
    网络类型               : 结构
    无线电类型             : 802.11g
    身份验证               : WPA2 - 个人
    密码                   : CCMP
    连接模式               : 自动连接
    信道                   : 6
    接收速率(Mbps)         : 144
    传输速率 (Mbps)        : 144
    信号                   : 91%
    配置文件               : CMCC 2

    承载网络状态  : 未启动


5. 查看配置文件

D:\Windows\system32>netsh wlan show profiles

接口 无线网络连接 上的配置文件:


组策略配置文件(只读)
---------------------------------
    <无>

用户配置文件
-------------
    所有用户配置文件 : ChinaNet
    所有用户配置文件 : CMCC-EDU
    所有用户配置文件 : CMCC 2
    所有用户配置文件 : CMCC
    所有用户配置文件 : hxcy_dating


6. 写批处理文件“CMCC-EDU.bat“,内容如下:

netsh wlan connect name="CMCC-EDU" interface="无线网络连接"

然后还是发送到桌面快捷方式,并建立快捷键,同样建一个”ChinaNet.bat“,这样就可以快速的在CMCC-EDU和ChinaNet之间切换了。






原创粉丝点击