Home > front end >  Close/Kill "Services" app from Powershell?
Close/Kill "Services" app from Powershell?

Time:12-15

I'm trying to kill the "Service" app (if it is open) from Powershell.

This does not work:

taskkill /F /FI "WindowTitle eq Services" /T

This does work, but it kills all the "mmc.exe":

taskkill /IM mmc.exe

Any idea how I can kill just the service app (service.msc)?

CodePudding user response:

process objects have a window title property you can use. Try something like this:

# view running processes
Get-Process 'mmc' | select id,name,MainWindowTitle

   Id Name MainWindowTitle
   -- ---- ---------------
18452 mmc  Services       
24828 mmc  Disk Management

# close only the services app
Get-Process 'mmc' | Where MainWindowTitle -eq 'Services' | Stop-Process

# verify other mmc processes did not stop:
Get-Process 'mmc' | select id,name,MainWindowTitle

   Id Name MainWindowTitle
   -- ---- ---------------
24828 mmc  Disk Management

CodePudding user response:

I have used this command and it works:

tasklist | findstr mmc.exe
TASKKILL /F /PID ID
  • Related