Jump to content

Need Some VB Help for WLAN Settings Automation


Recommended Posts

I am trying to automate WLAN adaptor settings with a vbscript. The same as doing a properties on WLAN adaptor and clicking on advanced tab.

The main registry path is consistent on every machine:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}

Problem is the subkey that houses the settings is not consistent. The subkeys will look something like this:

0001

0002

0003

0004

0005

0006

0007

0008

I am trying to figure out a way to search the subkeys for a value that is unique to my WLAN adaptors (Which are all Broadcom) and then once the subkey is identified (0008 for example) write the values that I want in there thus automating the configuration.

Here is an example of my WLAN card registry key:

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}008]"ledbh0"="-1"

"ledbh1"="-1"

"ledbh2"="-1"

"ledbh3"="-1"

"leddc"="0xa0000"

"Interference_Mode"="-1"

"ccx_rm"="1"

"ccx_rm_limit"="300"

"EFCEnable"="0"

"Chanspec"="11"

"WME"="0"

"abcap"="1"

"AssocRoamPref"="1"

"10280009"="Dell Wireless 1500 Draft 802.11n WLAN Mini-Card"

"Characteristics"=dword:00000084

"BusType"="5"

"ComponentId"="pci\\ven_14e4&dev_4328&subsys_00091028"

"11HNetworks"="1"

"Afterburner"="1"

"antdiv"="-1"

"ApCompatMode"="0"

"BandPref"="0"

"BandwidthCap"="1"

"BTCoexist"="0"

"frag"="2346"

"FrameBursting"="1"

"IBSSAllowed"="1"

"IBSSGProtection"="2"

"IBSSMode"="0"

"LegacyMode"="2"

"LOM"="1"

"Managed"="1"

"MPC"="0"

"PLCPHeader"="0"

"PowerSaveMode"="2"

"RadioState"="0"

"Rate"="0"

"RateA"="0"

"RoamDelta"="1"

"RoamTrigger"="0"

"rts"="2347"

"ssid_auto_promote"="0"

"vlan_mode"="0"

"WZCCoexist"="0"

"Country"="US"

"band"="0"

"InfPath"="oem0.inf"

"InfSection"="BCM1500M"

"InfSectionExt"=".NT"

"ProviderName"="Broadcom"

"DriverDateData"=hex:00,40,3a,5c,91,ed,c6,01

"DriverDate"="10-12-2006"

"DriverVersion"="4.100.15.5"

"MatchingDeviceId"="pci\\ven_14e4&dev_4328&subsys_00091028"

"DriverDesc"="Dell Wireless 1500 Draft 802.11n WLAN Mini-Card"

"NetCfgInstanceId"="{7C7903A1-30F1-4BC5-8323-CCBF1AA7F779}"

I know you can do the same thing with a bcmpn.wpn profile:

http://support.dell.com/support/topics/glo...0401E0A551752E7

It works flawlessly if the machine is fresh but if the adaptor or wireless connection reads with a 1,2,3 at the end of the name it stops working. I really need a solution that will work no matter what.

VB Gurus help me out :)

Link to comment
Share on other sites


I'm not sure if the syntax is correct but this should get you started.

On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
On Error GoTo NoMoreKeys
For I = 0 To 9999
WshShell.RegRead "HKLM\...\" & Trim(Format(I+1,"0000")) & "\"
Next
NoMoreKeys:
On Error Resume Next
For I = I To 1 Step -1
If WshShell.RegRead("HKLM\...\" & Trim(Format(I,"0000")) "\...")="Value"
WshShell.RegWrite "HKLM\...\" & Trim(Format(I,"0000")) "\...", "Value", "Type"
End If
Next

Link to comment
Share on other sites

Problem with On Error Resume Next is that your code will not be working efficiently. Any number of ill-effects can occur with that in each function or procedure.

The reason I put it there is because RegRead will raise an error if the value I'm looking for doesn't exist and I want to ignore these errors.

Link to comment
Share on other sites

I get some errors

On Error Resume Next

Set WshShell = WScript.CreateObject("WScript.Shell")

*On Error GoTo NoMoreKeys

For I = 0 To 9999

WshShell.RegRead "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I+1,"0000")) & "\"

Next

NoMoreKeys:

On Error Resume Next

For I = I To 1 Step -1

If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000"))) ("\Afterburner"="1") then

*WshShell.RegWrite ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000"))) ("\Works", "1", "REG_SZ")

End If

Next

On line 3 when it is not commented out I get an invalid syntax error.

On line 11 I get "cannot use parentheses when calling a sub". If I don't put the parenthesis in there it gives expected end of statement.

Edited by snooz
Link to comment
Share on other sites

On line 3 when it is not commented out I get an invalid syntax error.

On line 11 I get "cannot use parentheses when calling a sub". If I don't put the parenthesis in there it gives expected end of statement.

This might work:

On Error Resume Next
For I = 0 To 9999
If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" then
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"
End If
Next

If you run RegMon you will see that this is not efficiant but it looks like it should work.

Link to comment
Share on other sites

On line 3 when it is not commented out I get an invalid syntax error.

On line 11 I get "cannot use parentheses when calling a sub". If I don't put the parenthesis in there it gives expected end of statement.

This might work:

On Error Resume Next
For I = 0 To 9999
If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" then
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"
End If
Next

If you run RegMon you will see that this is not efficiant but it looks like it should work.

I don't care about the efficiency too much.

I am using this reg key

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}020]"Afterburner"="1"

I tested this script

On Error Resume Next

For I = 0 To 9999

If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" then

WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"

End If

Next

Didn't work for me and I also did a regmon and I don't see any activity in this location:

HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}

Edited by snooz
Link to comment
Share on other sites

On line 3 when it is not commented out I get an invalid syntax error.

On line 11 I get "cannot use parentheses when calling a sub". If I don't put the parenthesis in there it gives expected end of statement.

This might work:

On Error Resume Next
For I = 0 To 9999
If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" then
WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"
End If
Next

If you run RegMon you will see that this is not efficiant but it looks like it should work.

I don't care about the efficiency too much.

I am using this reg key

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}020]"Afterburner"="1"

I tested this script

On Error Resume Next

For I = 0 To 9999

If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" then

WshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"

End If

Next

Didn't work for me and I also did a regmon and I don't see any activity in this location:

HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}

Oops I forgot this line:

Set WshShell = WScript.CreateObject("WScript.Shell")

It should be the first line

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...