Advertisement
emga9xkc

UDF Enable Disable card and UAC Autoit

Feb 13th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.04 KB | None | 0 0
  1. #RequireAdmin
  2. #include<Array.au3>
  3. ;~ _Reg_UAC(0)
  4. ;~ _ArrayDisplay(__GetAllCard())
  5. ;~ __Card(Default,False)
  6.  
  7. Func __GetAllCard()
  8.     Local $return[0]
  9.    Const $ssfCONTROLS = 49
  10.     $ShellApp = ObjCreate("Shell.Application")
  11.     $oNetConnections = $shellApp.Namespace($ssfCONTROLS)
  12.     For $FolderItem In $oNetConnections.Items
  13.             Local $temp[UBound($return)]
  14.             For $k=0 To UBound($return)-1
  15.                 $temp[$k]=$return[$k]
  16.             Next
  17.             Local $return[UBound($temp)+1]
  18.             For $k=0 To UBound($return)-2
  19.                 $return[$k]=$temp[$k]
  20.             Next
  21.             $return[UBound($return)-1]=$FolderItem.Name
  22.    Next
  23.     Return $return
  24. EndFunc
  25.  
  26. Func __Card($oLanConnection="Wi-Fi", $bEnable=True)
  27.     Local $strEnableVerb  = "En&able"
  28.     Local $strDisableVerb = "Disa&ble"
  29.     if @OSType<>"WIN32_NT" then
  30.         Msgbox(0,"","This script requires Windows 2000 or higher.")
  31.         exit
  32.     endif
  33.     if @OSVersion="WIN_2000" then
  34.         $strFolderName = "Network and Dial-up Connections"
  35.     else
  36.         $strFolderName = "Network Connections"; Windows XP
  37.     endif
  38.     ;Virtual folder containing icons for the Control Panel applications. (value = 3 Or 49)
  39.     Const $ssfCONTROLS = 49
  40.     $ShellApp = ObjCreate("Shell.Application")
  41.     $oNetConnections = $shellApp.Namespace($ssfCONTROLS)
  42.     For $FolderItem In $oNetConnections.Items
  43.         If StringLower($FolderItem.Name) = StringLower($oLanConnection) Then
  44.             $oLanConnection = $FolderItem
  45.             ConsoleWrite($FolderItem.Name&@CRLF)
  46.             Exitloop
  47.         EndIf
  48.     Next
  49.     If not IsObj($oLanConnection) Then
  50.         MsgBox(0,"Error","Couldn't find " & $oLanConnection & " Item."
  51.         Exit
  52.     EndIf
  53.     $oEnableVerb=""
  54.     $oDisableVerb=""
  55.     For $Verb In $oLanConnection.Verbs
  56.         ConsoleWrite($Verb.Name&@CRLF)
  57.     If $Verb.Name = $strEnableVerb Then
  58.         $oEnableVerb = $Verb
  59.     EndIf
  60.     If $Verb.Name = $strDisableVerb Then
  61.         $oDisableVerb = $Verb
  62.     EndIf
  63.     Next
  64.     If $bEnable then
  65.         If IsObj($oEnableVerb) Then $oEnableVerb.DoIt    ; Enable network card
  66.     Endif
  67.     If not $bEnable then
  68.     If IsObj($oDisableVerb) Then $oDisableVerb.DoIt; Disable network card
  69.     EndIf
  70.     Sleep(1000)
  71. EndFunc
  72.  
  73. Func _Reg_UAC($iState = 5);0: disable 5:enable
  74.    Local $sRegKey, $sRegValue
  75.    $sRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
  76.    $sRegValue = "ConsentPromptBehaviorAdmin"
  77.    If @OSVersion <> ("WIN_VISTA" Or "WIN_7") Then
  78.       Return SetError(1, 0, -1)
  79.    EndIf
  80.    RegWrite($sRegKey, $sRegValue, "REG_DWORD", $iState)
  81. EndFunc   ;==>_Reg_UAC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement