Jump to content

remote task kill


pcjunki
 Share

Recommended Posts

i've made a simple gui, to help automate killing running tasks on remote pc

thought i'd share

#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Remote task kill 1.1", 362, 135, 214, 147)
$Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17)
$Input1 = GUICtrlCreateInput("", 8, 24, 137, 21)
$combo = GUICtrlCreateCombo("", 152, 24, 193, 25)
GUICtrlSetData(-1, "Task_List|taskkill_Outlook|taskkill_notepad")
$Button1 = GUICtrlCreateButton("run", 272, 48, 73, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$app = GUICtrlRead($combo)
$pc = GUICtrlRead($Input1)
Call($app, $pc)
EndSwitch
WEnd

Func task_list($pc)
Run(@ComSpec & " /k tasklist /s " & $pc)
EndFunc

Func taskkill_Outlook($pc)
Run(@ComSpec & " /k taskkill /s \\" & $pc & " /im outlook.exe" )
EndFunc

Func taskkill_notepad($pc)
Run(@ComSpec & " /k taskkill /s \\" & $pc & " /im notepad.exe" )
EndFunc
Link to comment
Share on other sites

this was too easy wasn't it :)

I suggest you try to make a small gui, use tasklist or pslist (sysinternals) they are both OK. to populate a process list in this gui, and doubleclicking one of the processes returned in the list prompts you to close the executable.. this is not as easy as you might think :)

Kind regards :)

Link to comment
Share on other sites

  • 5 years later...
On 8/16/2012 at 10:16 AM, pcjunki said:

i've made a simple gui, to help automate killing running tasks on remote pc

thought i'd share

 

 

 

#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Remote task kill 1.1", 362, 135, 214, 147)
$Label1 = GUICtrlCreateLabel("Computer Name", 8, 8, 80, 17)
$Input1 = GUICtrlCreateInput("", 8, 24, 137, 21)
$combo = GUICtrlCreateCombo("", 152, 24, 193, 25)
GUICtrlSetData(-1, "Task_List|taskkill_Outlook|taskkill_notepad")
$Button1 = GUICtrlCreateButton("run", 272, 48, 73, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$app = GUICtrlRead($combo)
$pc = GUICtrlRead($Input1)
Call($app, $pc)
EndSwitch
WEnd

Func task_list($pc)
Run(@ComSpec & " /k tasklist /s " & $pc)
EndFunc

Func taskkill_Outlook($pc)
Run(@ComSpec & " /k taskkill /s \\" & $pc & " /im outlook.exe" )
EndFunc

Func taskkill_notepad($pc)
Run(@ComSpec & " /k taskkill /s \\" & $pc & " /im notepad.exe" )
EndFunc

Thanks for this... How would you modify this script to have it run as an admin on the remote server (that has the appropriate permissions to kill the process)?

Link to comment
Share on other sites

You should be able to use RunAs instead of Run and specify credentials...a few comments however.

It is not wise to store usernames and passwords in a script.  You should consider storing them in another, protected file outside the script.  
Is this in a domain (AD) environment?  If possible, execute the script as the user with admin rights on the remote server and avoid storing credentials at all,
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...