#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
$GUI=GUICreate("ProcessClose",500, 600, 100, 200,$GUI_SS_DEFAULT_GUI)
$Cuilistview = GUICtrlCreateListView("№|Name|PID ", 10, 10, 280, 450)
$GuiLabelComp = GUICtrlCreateLabel("Ip - addres",300,8,120,30)
$GuiInputComp = GUICtrlCreateInput("",300,30,150,30)
$GuiLabelName = GUICtrlCreateLabel("Name User",300,80,120,30)
$GuiInputName = GUICtrlCreateInput("",300,100,150,30)
$GuiLabelPass = GUICtrlCreateLabel("Pass User",300,150,120,30)
$GuiInputPass = GUICtrlCreateInput("",300,170,150,30)
$GuiLabelPass = GUICtrlCreateLabel("PID",300,200,120,30)
$GuiInputPid = GUICtrlCreateInput("",300,230,150,30)
$butoon1 = GUICtrlCreateButton("Get Proc", 300,280,150,30)
$butoon2 = GUICtrlCreateButton("Kill Proc", 300,330,150,30)
ControlDisable($GUI,"",$butoon2 )
ControlDisable($GUI,"",$GuiInputPid )
GUISetState()
$msg = GUIGetMsg()
while $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
case $msg = $butoon1
$Comp = GUICtrlRead ($GuiInputComp)
$Name = GUICtrlRead ($GuiInputName)
$Pass = GUICtrlRead ($GuiInputPass)
if $Comp="" or $Name = "" or $Pass = "" Then
MsgBox(64,"Не заполнены поля", "Не заполнены некоторые поля")
else
_GetProc($Comp,$Name,$Pass)
ControlEnable($GUI,"",$butoon2 )
ControlEnable($GUI,"",$GuiInputPid )
EndIf
Case $msg = $butoon2
$Comp = GUICtrlRead ($GuiInputComp)
$Name = GUICtrlRead ($GuiInputName)
$Pass = GUICtrlRead ($GuiInputPass)
$PID = GUICtrlRead ($GuiInputPid )
if $PID = "" then
MsgBox(64,"Не заполнено поле PID", "Не заполнено поле PID")
Else
_ProcClose ($Comp,$Name,$Pass, $PID)
EndIf
EndSelect
wend
Func _ProcClose ($strComputer,$strUser,$strPassword, $ProcName)
$strDomain = "DOMAIN"
$objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
$objWMIServiceProc = $objSWbemLocator.ConnectServer( $strComputer,"root\CIMV2",$strUser,$strPassword,"MS_409", "ntlmdomain:" & $strDomain)
$objShare = $objWMIServiceProc.Get("Win32_Process.Handle=" & $ProcName)
$objInParam = $objShare.Methods_("Terminate").inParameters.SpawnInstance_()
$objOutParams = $objWMIServiceProc.ExecMethod("Win32_Process.Handle=" & $ProcName, "Terminate", $objInParam)
EndFunc
Func _GetProc($strComputer,$strUser,$strPassword)
$strDomain = "DOMAIN"
$objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
$objWMIServiceProc = $objSWbemLocator.ConnectServer( $strComputer,"root\CIMV2",$strUser,$strPassword,"MS_409", "ntlmdomain:" & $strDomain)
$colItems = $objWMIServiceProc.ExecQuery( "SELECT * FROM Win32_Process")
$item1 = 0
For $objItem in $colItems
$item1 +=1
ConsoleWrite ($objItem.Caption & " " & $objItem.Handle & @CR)
GUICtrlCreateListViewItem($item1 &"|" & $objItem.Caption &"|"& $objItem.Handle, $Cuilistview)
Next
EndFunc