Advertisement
aveyo

wifi_scan_toggle

Nov 3rd, 2016
5,291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.57 KB | None | 0 0
  1. <!-- : class="re0">Change MAC by AveYo v3.0  / Wi-Fi Scan Toggle v1.0
  2. @ECHO OFF &SETLOCAL ENABLEEXTENSIONS
  3. GOTO :_INIT
  4.  
  5. :_START
  6. CALL "%SSVAR%\cscript.exe" //nologo "%~f0?.wsf" //job:SCAN
  7. rem CALL "%SSVAR%\cscript.exe" //nologo "%~f0?.wsf" //job:MAC
  8. EXIT /B
  9.  
  10. :_INIT
  11. CD /D "%~dp0"
  12. SET "SSVAR=%WINDIR%\SYSTEM32"
  13. IF DEFINED PROCESSOR_ARCHITEW6432 SET "SSVAR=%WINDIR%\Sysnative"
  14. MODE 80,2 &COLOR 70 &TITLE %~n0 by A^v^eY^o^ v3^.^0
  15. IF "%1"=="_SELF_ADMIN" SHIFT &SHIFT &GOTO :_START
  16. "%SSVAR%\REG.EXE" QUERY "HKEY_USERS\S-1-5-20\Environment" /v TEMP 2>NUL 1>&2 && GOTO :_START || echo Requesting admin rights, if it fails, R-click and 'Run As Administrator' &COLOR 0c
  17. CALL "%SSVAR%\cscript.exe" //nologo "%~f0?.wsf" //job:ADM "%~f0" &EXIT
  18. GOTO :eof
  19.  
  20. ----- embeded wsh scripts --->
  21. <package>
  22.   <job id="ADM">
  23.     <script language="VBScript">
  24.       On Error Resume Next
  25.       CreateObject("Shell.Application").ShellExecute WScript.Arguments(0), "_SELF_ADMIN " & WScript.Arguments(0), "", "runas", 1
  26.       Err.Clear
  27.     </script>
  28.   </job>
  29.   <job id="SCAN">
  30.     <script language="VBScript">
  31.       On Error Resume Next
  32.       const HKEY_LOCAL_MACHINE = &H80000002
  33.       Dim aName,aIndex,aInterface,aType,aChoice,aScan,aAutoconfig
  34.       Set aREG=GetObject("winmgmts:StdRegProv")
  35.       aKey = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"
  36.       Set aWMI = GetObject ("winmgmts:") '48=wbemFlagForwardOnly + wbemFlagReturnImmediately
  37.       Set adapters = aWMI.ExecQuery("Select NetEnabled,PhysicalAdapter,PNPDeviceID,ProductName,Index,NetConnectionID from Win32_NetworkAdapter where PhysicalAdapter=True and (PNPDeviceID LIKE '%USB%' or PNPDeviceID LIKE '%PCI%')","WQL",48)
  38.       For Each adapter in adapters
  39.       With adapter
  40.               aName = .ProductName
  41.               aIndex = "\" & Right("0000" & .Index, 4)
  42.         aInterface = .NetConnectionID
  43.         aREG.GetDWORDValue HKEY_LOCAL_MACHINE,aKey & aIndex,"*MediaType",aType
  44.         If aType = 16 Then
  45.             aChoice = MsgBox(chr(34) & aInterface & chr(34) & vbCrLf & aName & vbCrLf & vbCrLf & "Press Yes to Disable autoconfig (Background Scan OFF)" & vbCrLf & "Press No to Enable autoconfig (Background Scan OFF)" & vbCrLf & "Press Cancel to Reset (Background Scan ON)",67,"Wi-Fi Scan Toggle by AveYo")
  46.             aScan = "0" : If aChoice = vbCancel Then aScan = &H1 Else aScan = &H0 End If
  47.           If aChoice = vbYes Then aAutoconfig="no" Else aAutoconfig="yes" End If
  48.             aREG.SetDWORDValue HKEY_LOCAL_MACHINE,aKey & aIndex,"bkScanEnable", aScan '(only works for Atheros / Killer)
  49.                     aREG.SetDWORDValue HKEY_LOCAL_MACHINE,aKey & aIndex,"ScanWhenAssociated", aScan '(only works for Intel)
  50.                     CreateObject("Shell.Application").ShellExecute "netsh", "wlan set autoconfig enabled=" & aAutoconfig & " interface=" & chr(34) & aInterface & chr(34), "", "", 0
  51.         End If
  52.       End With
  53.       Next
  54.       Err.Clear
  55.     </script>
  56.   </job>
  57.   <job id="MAC">
  58.     <script language="VBScript">
  59.       On Error Resume Next
  60.       const HKEY_LOCAL_MACHINE = &H80000002
  61.       Dim aName,aMAC,aIndex,filterMAC
  62.       Set aREG=GetObject("winmgmts:StdRegProv")
  63.       aKey = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"
  64.       aValue = "NetworkAddress"
  65.       Set aWMI = GetObject ("winmgmts:") '48=wbemFlagForwardOnly + wbemFlagReturnImmediately
  66.       Set adapters = aWMI.ExecQuery("Select PhysicalAdapter,PNPDeviceID,ProductName,Index,NetEnabled from Win32_NetworkAdapter where PhysicalAdapter=True and (PNPDeviceID LIKE '%USB%' or PNPDeviceID LIKE '%PCI%')","WQL",48)
  67.  
  68.       For Each adapter in adapters
  69.       With adapter
  70.              aName = .ProductName
  71.              aIndex = "\" & Right("0000" & .Index, 4)
  72.        aREG.GetStringValue HKEY_LOCAL_MACHINE,aKey & aIndex,aValue,aMAC
  73.              If IsNull(aMAC) Then aMAC=""
  74.             changeMAC=Trim(InputBox(aName & vbCrLf & vbCrLf & "Enter new MAC address: (any separator .,: works)" & vbCrLf & "or 0 to reset it", "ChangeMac by AveYo", aMAC))
  75.                     filterMAC=Split("._ _,_:_;_-_<_>_[_]_{_}_(_)","_")
  76.           For each x in filterMAC
  77.           changeMAC=Replace(changeMAC,x,"")
  78.                     WScript.Echo changeMAC
  79.           Next
  80.           If changeMAC <> aMAC And changeMAC <> "" Then
  81.                        If changeMAC="0" Then aREG.DeleteValue HKEY_LOCAL_MACHINE,aKey & aIndex,aValue Else aREG.SetStringValue HKEY_LOCAL_MACHINE,aKey & aIndex,aValue,changeMAC End If
  82.              'If (.NetEnabled) Then adapter.disable() Else adapter.enable()
  83.              'If Not (.NetEnabled) Then adapter.enable() Else adapter.disable()
  84.                     End If
  85.          End With
  86.       Next
  87.       Err.Clear
  88.     </script>
  89.   </job>
  90. </package>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement