#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiIPAddress.au3>
#RequireAdmin
#NoTrayIcon
Global $aIni_Section = IniReadSection("IPs.ini", "Students IP")
If @error Then Exit 2
Global $aIP_CheckBoxes[$aIni_Section[0][0]], $aIP_Inputs[$aIni_Section[0][0]]
Global $iTopPos = 15, $iLeftPos = 15
Global $sCommentText = "Ты плохо себя вел"
$hMain = GUICreate("Administrator", 440, 220, -1, -1)
For $i = 1 To $aIni_Section[0][0]
$aIP_CheckBoxes[$i - 1] = GUICtrlCreateCheckbox($aIni_Section[$i][0], $iLeftPos, $iTopPos, 100, 25)
$aIP_Inputs[$i - 1] = _GUICtrlIpAddress_Create($hMain, $iLeftPos + 110, $iTopPos, 150, 25)
_GUICtrlIpAddress_Set($aIP_Inputs[$i - 1], $aIni_Section[$i][1])
$iTopPos += 30
Next
$idShutdown = GUICtrlCreateButton("Выключить", 300, 50, 120, 30)
$idReboot = GUICtrlCreateButton("Перезагрузить", 300, 80, 120, 30)
$idLogout = GUICtrlCreateButton("Выйти из системы", 300, 110, 120, 30)
GUISetState(@SW_SHOW, $hMain)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $idShutdown
_Actions("-s")
Case $idReboot
_Actions("-r")
Case $idLogout
_Actions("-l")
EndSwitch
WEnd
Func _Actions($sAction)
For $i = 0 To UBound($aIP_CheckBoxes) - 1
If _IsChecked($aIP_CheckBoxes[$i]) Then
Run(@ComSpec & ' /c shutdown ' & $sAction & ' -t 15 -c "'& $sCommentText & '" -m \\' & _GUICtrlIpAddress_Get ($aIP_Inputs[$i]), '', @SW_HIDE)
;~ ConsoleWrite(@ComSpec & ' /c shutdown ' & $sAction & ' -t 15 -c "'& $sCommentText & '" -m \\' & _GUICtrlIpAddress_Get ($aIP_Inputs[$i]) & @CRLF)
EndIf
Next
EndFunc
Func _IsChecked($idControlID)
Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked