Posts Tagged Process
Terminate Process
Posted by admin in Powershell on October 11, 2009
While wanting to kill a process, i decided why use the task manager when i can use powershell. I will be using wmi and the Win32_Process class for this task.
First i look for the process name i would like to terminate:
1 | gwmi win32_process | select-object name |
I then select the process name from this list to confirm this is the process i want to terminate:
1 | gwmi win32_process | where {$_.name -eq "AdobeUpdater.exe"} |
Then i terminate it:
1 | (gwmi win32_process | where {$_.name -eq "AdobeUpdater.exe"}).terminate() |
We are looking for a return value of 0 indicating this was successfull:
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0For other return values, visit MSDN for more information.