snooz Posted January 17, 2007 Share Posted January 17, 2007 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:00010002000300040005000600070008I 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...0401E0A551752E7It 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 More sharing options...
Bezalel Posted January 18, 2007 Share Posted January 18, 2007 I'm not sure if the syntax is correct but this should get you started.On Error Resume NextSet WshShell = WScript.CreateObject("WScript.Shell")On Error GoTo NoMoreKeysFor I = 0 To 9999 WshShell.RegRead "HKLM\...\" & Trim(Format(I+1,"0000")) & "\"NextNoMoreKeys:On Error Resume NextFor 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 IfNext Link to comment Share on other sites More sharing options...
Tarun Posted January 18, 2007 Share Posted January 18, 2007 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. Link to comment Share on other sites More sharing options...
Bezalel Posted January 18, 2007 Share Posted January 18, 2007 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 More sharing options...
snooz Posted January 18, 2007 Author Share Posted January 18, 2007 (edited) I get some errorsOn Error Resume NextSet WshShell = WScript.CreateObject("WScript.Shell")*On Error GoTo NoMoreKeysFor I = 0 To 9999 WshShell.RegRead "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I+1,"0000")) & "\"NextNoMoreKeys:On Error Resume NextFor 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 IfNextOn 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 January 18, 2007 by snooz Link to comment Share on other sites More sharing options...
Bezalel Posted January 19, 2007 Share Posted January 19, 2007 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 NextFor I = 0 To 9999If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" thenWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"End IfNextIf 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 More sharing options...
snooz Posted January 19, 2007 Author Share Posted January 19, 2007 (edited) 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 NextFor I = 0 To 9999If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" thenWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"End IfNextIf 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 keyWindows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}020]"Afterburner"="1"I tested this scriptOn Error Resume NextFor I = 0 To 9999If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" thenWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"End IfNextDidn'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 January 19, 2007 by snooz Link to comment Share on other sites More sharing options...
Bezalel Posted January 19, 2007 Share Posted January 19, 2007 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 NextFor I = 0 To 9999If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" thenWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"End IfNextIf 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 keyWindows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}020]"Afterburner"="1"I tested this scriptOn Error Resume NextFor I = 0 To 9999If WshShell.RegRead ("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Afterburner") = "1" thenWshShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\" & Trim(Format(I,"0000")) & "\Works", "1", "REG_SZ"End IfNextDidn'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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now