|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
802.1x - script to configure EAP on 1000 desktops
I got an script that have a good ideia, but have one problem. Whem it not found the registry entry the script stops with an error. The strange thing is, some desktops have the registry setting on the right place and others there nothing. The script read a value in the registry, change the value and wirte again, but some SID network adapter are not found. why? any1 can help to make a IF ELSE in the script bellow: Dim oWshShell, oWMISvc Set oWshShell = Wscript.CreateObject("Wscript.shell") Set oWMISvc = GetObject("winmgmts:\\.\root\cimv2") Dim arrNicGUID() iGUIDCount=0 For Each oNicGUID In oWMISvc.ExecQuery("select * from Win32_NetworkAdapter where AdapterType=" & chr (34) & "Ethernet 802.3" & chr(34)) szNicInstanceID = Right(("000" & oNicGUID.DeviceID),4) szNicGUID = oWshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\"_ & szNicInstanceID & "\NetCfgInstanceId") ReDim preserve arrNicGUID(iGUIDCount) arrNicGUID(iGUIDCount) = szNicGUID iGUIDCount = iGUIDCount + 1 Next For i = 0 To UBound(arrNicGUID) WScript.Echo arrNicGUID(i) Next Dim oFSO,oTFOReg szRegFile = "C:\Temp\EAPOL.reg" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oTFOReg = oFSO.OpenTextFile(szRegFile,2,True) oTFOReg.WriteLine("Windows Registry Editor Version 5.00") oTFOReg.WriteBlankLines(1) oTFOReg.WriteLine("[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\EAPOL\Parameters\General\Global]") oTFOReg.WriteLine(chr(34) & "SupplicantMode" & chr(34) & "=dword:00000003") oTFOReg.WriteLine(chr(34) & "AuthMode" & chr(34) & "=dword:00000001") For iGUID = LBound(arrNicGUID) To UBound(arrNicGUID) oTFOReg.WriteBlankLines(1) oTFOReg.WriteLine "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\" & arrNicGUID(iGUID) & "]" oTFOReg.Write chr(34) & "1" & chr(34) & "=hex:" arrEAPOLSet = oWshShell.RegRead("HKLM\SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"& arrNicGUID(iGUID) & "\1") For iEAPOLByte = LBound(arrEAPOLSet) To 10 oTFOReg.write hex(arrEAPOLSet(iEAPOLByte)) &"," Next oTFOReg.Write "e0,19" For iEAPOLByte = 13 To UBound(arrEAPOLSet) oTFOReg.write "," & hex(arrEAPOLSet(iEAPOLByte)) Next oTFOReg.writeLine() Next oTFOReg.Close oWshShell.Run"regedit /s " & szRegFile, 1, TRUE |
|||||||||||||||||||||||