topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 5:38 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Idea: Task Manager "Lite"  (Read 3589 times)

AzureToad

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 95
    • View Profile
    • Read more about this member.
    • Donate to Member
Idea: Task Manager "Lite"
« on: May 16, 2020, 07:06 PM »
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
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Re: Idea: Task Manager "Lite"
« Reply #1 on: May 16, 2020, 09:38 PM »
Save to a .ps1 file and run

Code: PowerShell [Select]
  1. #Process Killer - allows the user to kill their own processes
  2.  
  3. #1. Initalize list of processes to exclude
  4. $processesToExclude = @(
  5.     'conhost', 'dwm', 'explorer', 'rundll32', 'taskhost'
  6. )
  7.  
  8. #2. Get the processes and add the list of processes and owners to the ownerList.
  9. $ownerList = @{}
  10. $procs = Get-WmiObject -Class Win32_Process
  11. ForEach($proc in $procs){$ownerList[$proc.Handle] = $proc.GetOwner().user}
  12.  
  13. #3. Create the master process list from the information retrieved above
  14. $masterProcessList = Get-Process | select processname,Description,Id,@{l="Owner";e={$ownerList[$_.id.tostring()]}}
  15.  
  16. #4. Filter out the processes for the current user
  17. $processList = @()
  18. ForEach($currentProcess in $masterProcessList)
  19. {
  20.     If($currentProcess.Owner -eq $env:USERNAME)
  21.     {
  22.         $processList += $currentProcess
  23.     }
  24. }
  25.  
  26. #5. Show interface with list of processes minus the ones we want to exclude
  27. $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, 05:39 PM by wraith808 »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Idea: Task Manager "Lite"
« Reply #2 on: May 16, 2020, 11:34 PM »
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.pngIdea: Task Manager "Lite"

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Re: Idea: Task Manager "Lite"
« Reply #3 on: May 16, 2020, 11:56 PM »
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: 95
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Idea: Task Manager "Lite"
« Reply #4 on: May 18, 2020, 03:47 PM »
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!

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, 03:55 PM by AzureToad »

publicdomain

  • Honorary Member
  • Joined in 2019
  • **
  • Posts: 732
  • Call me Vic!
    • View Profile
    • Donate to Member
Re: Idea: Task Manager "Lite"
« Reply #5 on: February 15, 2021, 08:01 PM »
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.dcmember...-killer-lite-v0-1-0/

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

Task Killer Lite thread: https://www.donation...ex.php?topic=51088.0

Cheers!
Vic
My name's Victor but do feel free to call me Vic!

Support with your DonationCredits!
❤️ Support on Patreon @ www.patreon.com/publicdomain
🎁 One-time Paypal @ www.paypal.com/paypalme/victorvls
Email/Paypal: publicdomainvicgmail.com