DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Idea: Task Manager "Lite"  (Read 7,420 times)

AzureToad

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 101
Idea: Task Manager "Lite"
« on: May 17, 2020, 12:06 AM »
For various reasons, we dont want to give access to TASKMGR.EXE on server sessions, but there are times when we do want them to be able to end a process that's frozen.

I'd like to present the user a prompt where they could key a username and/or a process name, showing results similar to what's found when TASKLIST is run. The user could then select a process and choose to kill it.

Task manager offers too many opportunities for the user to gain access to the desktop of the server or to run programs we'd rather they not have.

I considered using PowerShell to prompt the user, run tasklist with output to CSV format, then taking that to display to the user and using taskkill.Exe to end the selected program. Unfortunately, I've never written a script even REMOTELY similar to this!

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 11,205
    • Participated in NANY Challenge Fourteen Times
    • Coding Snacks
    • Writer
    • Hardware Hacker
Re: Idea: Task Manager "Lite"
« Reply #1 on: May 17, 2020, 02:38 AM »
Save to a .ps1 file and run

Code: (powershell)
#Process Killer - allows the user to kill their own processes 

#1. Initalize list of processes to exclude
$processesToExclude = @(
    'conhost', 'dwm', 'explorer', 'rundll32', 'taskhost' 
)

#2. Get the processes and add the list of processes and owners to the ownerList.
$ownerList = @{}
$procs = Get-WmiObject -Class Win32_Process
ForEach($proc in $procs){$ownerList[$proc.Handle] = $proc.GetOwner().user}

#3. Create the master process list from the information retrieved above
$masterProcessList = Get-Process | select processname,Description,Id,@{l="Owner";e={$ownerList[$_.id.tostring()]}}

#4. Filter out the processes for the current user
$processList = @()
ForEach($currentProcess in $masterProcessList)
{
    If($currentProcess.Owner -eq $env:USERNAME)
    {
        $processList += $currentProcess
    }
}

#5. Show interface with list of processes minus the ones we want to exclude
$processList | Where{$_.ProcessName -notin $processesToExclude} | Out-GridView -Title 'Process Killer - Select the process that you want to kill. Select multiple with the Ctrl or Shift key.' -PassThru | ForEach{Stop-Process -id $_.Id}
« Last Edit: May 18, 2020, 10:39 PM by wraith808 »

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Idea: Task Manager "Lite"
« Reply #2 on: May 17, 2020, 04:34 AM »
Save to a .ps1 file and run

Ha!  Spent 90 mins trying to get the output from Get-WmiObject into a ListView ... and gave up :-[

I was going for something using a GUI, still haven't quite worked out getting arrays into a ListView yet.
2020-05-17 14_32_24-PTM.png
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 11,205
    • Participated in NANY Challenge Fourteen Times
    • Coding Snacks
    • Writer
    • Hardware Hacker
Re: Idea: Task Manager "Lite"
« Reply #3 on: May 17, 2020, 04:56 AM »
I cheated.  I'd had to do something like this a while ago, so had the code sitting around.  Just needed to clean it up!

AzureToad

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 101
Re: Idea: Task Manager "Lite"
« Reply #4 on: May 18, 2020, 08:47 PM »
Quote
Save to a .ps1 file and run
Holy smoke! This is fabulous - does what I was looking for and... the code... so dang compact!
Very nice, thank you!

Quote
I cheated worked smarter, not harder
FTFY

Not only got a tool I can use, but got an education as well!
Turned out to be a pretty good Monday.  :P

Enjoy the credit. Credit and half?  :Thmbsup:
« Last Edit: May 18, 2020, 08:55 PM by AzureToad »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 732
    • Participated in NANY Challenge Three Times
    • Linux User
Re: Idea: Task Manager "Lite"
« Reply #5 on: February 16, 2021, 02:01 AM »
Here's a standard GUI program based on this idea (using the same exclusion list):

For single-program termination: fire it up, kill a program, done :)

TaskKillerLite_v0.1.0.png


(Can also refresh list via File/New)

DCmembers download: https://www.dcmembers.com/publicdomainvic/download/task-killer-lite-v0-1-0/

GitHub sources: https://github.com/publicdomain/task-killer-lite

Task Killer Lite thread: https://www.donationcoder.com/forum/index.php?topic=51088.0

Cheers!
Vic

Original address: https://www.donationcoder.com/forum/index.php?topic=49923.0