Advertisement
TrunghieuTH10

Disable - Enable Network Connections

Oct 9th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.64 KB | None | 0 0
  1. #RequireAdmin
  2. #include <File.au3>
  3. MsgBox(16,'',_NetworkConnections('Disable'))
  4. MsgBox(64,'',_NetworkConnections('Enable'))
  5.  
  6. Func _NetworkConnections($action = 'Disable')
  7.     Local $tmpfile =  _TempFile(), $data
  8.     If FileExists($tmpfile) Then FileDelete($tmpfile)
  9.     RunWait(@ComSpec & " /c " & 'wmic nic get netconnectionid>'&$tmpfile,'',@SW_HIDE)
  10.     For $i = 2 to _FileCountLines($tmpfile)
  11.         $data = StringStripWS(FileReadLine($tmpfile, $i),3)
  12.         If Not $data = '' Then RunWait(@ComSpec & " /c " & 'netsh interface set interface "'& $data & '" ' &$action,'',@SW_HIDE)
  13.     Next
  14.     FileDelete($tmpfile)
  15.     Return 'Network connections is ' & $action &'d'
  16. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement