Notification

Icon
Error

Tasklist Task Kill action

Posted: Friday, March 30, 2012 1:07:27 AM(UTC)
danielm

danielm

Member Original PosterPosts: 187
1
Like
A simple way to see tasks on remote pcs and then kill them the lazy way

TASK LIST

Code:
cmd.exe /K {actionpath}pslist.exe -s -r 3 \\{computer}


The options set it to open a dos window and refresh every 3 seconds so you can see whats up.
pslist is from PStools kit you can get from microsoft at www.sysinternals.com


TASK KILL

Code:
{actionpath}taskkill.bat {computer}


the batch file would read. It just asks for the ID of the process or the name. allows repeat.
the NAMEOFSERVERHERE needs to be your server incase you do not have pskill locally :) i just put it on the lansweeper server share.

Code:

@echo off
if %1.==. GOTO END

:STARTOFKILL
ECHO.
@ECHO Preparing to kill Process on computer %1
REM Clearing variables
set killprocess=
set killagain=
set idkill=

ECHO.
set /p killprocess=Do you wish to kill a process (n/y) [enter=skip]?
if {%killprocess%}=={y} goto yeskill
if {%killprocess%}=={n} goto nokill
if %killprocess%.==. goto nokill
goto nokill
:yeskill
set /p idkill=Enter number only of ID to delete [process name or process id]?
\\NAMEOFSERVERHERE\lansweeper$\pskill.exe \\%1 %idkill%

set /p killagain=Do you wish to kill another process (n/y) [enter=skip]?
if {%killagain%}=={y} goto STARTOFKILL
if {%killagain%}=={n} goto noagainkill
:noagainkill

:nokill

ECHO.
ECHO Press any key to close this window...
pause>nul

GOTO END

:BLANK
:END

danielm
#1danielm Member Original PosterPosts: 187  
posted: 1/19/2018 10:36:17 PM(UTC)
Also to add,
I noticed after some time the commands stopped working on some remote machines. the pslist and such would return an error.
in any case I was able to solve them like this. Mainly I think it's due to remote registry not being on, which you may not want on all the time...
I am just doing it multiple times bellow for informative purposes so you know if its on or off. But, you could just do the start and stop if you do not care about verification.

so

Start_RR
Code:

cmd /K sc \\{smartname} query remoteregistry & sc \\{smartname} start remoteregistry & sc \\{smartname} query remoteregistry & pause & exit


Stop RR
Code:

cmd /K sc \\{smartname} query remoteregistry & sc \\{smartname} stop remoteregistry & sc \\{smartname} query remoteregistry & pause & exit

Active Discussions

Lansweeper History of relationship between pc and monitor
by  hfaddy  
Go to last post Go to first unread
Last post: 9/17/2021 1:44:38 PM(UTC)
Lansweeper New Hire Login Request Report
by  Scott Davis   Go to last post Go to first unread
Last post: 9/16/2021 7:16:46 PM(UTC)
Lansweeper SCCM end of life
by  Esben.D  
Go to last post Go to first unread
Last post: 9/16/2021 2:56:23 PM(UTC)
Lansweeper Microsoft Patch Tuesday – September 2021
by  Esben.D  
Go to last post Go to first unread
Last post: 9/14/2021 8:27:06 PM(UTC)
Lansweeper Apple “FORCEDENTRY” Zero-Day Vulnerability
by  Esben.D   Go to last post Go to first unread
Last post: 9/14/2021 12:07:54 PM(UTC)
Lansweeper ALL laptops HP 340S G7 Notebook PC and Bios version
by  Carlos Montes  
Go to last post Go to first unread
Last post: 9/13/2021 3:17:19 PM(UTC)