Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In powershell, if I do 'get-process', I get

PS C:\Documents and Settings\Hello\Desktop> get-process -name excel

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
    312      11    13124      25196   121    58.50  13180 EXCEL

However, using ps from mkstools I can get these:

C:\\workarea\>ps | grep -i excel
13964 12:17 "C:\PROGRA~1\MICROS~2\Office10\excel.exe"  
16144 31:12 "C:\PROGRA~1\MICROS~2\Office10\excel.exe"  
13180  0:58 "C:\Program Files\Microsoft Office\Office10\excel.exe" /automation -Embedding
12624  0:56 "C:\Program Files\Microsoft Office\Office10\excel.exe" /automation -Embedding
12388  0:00 "C:\Program Files\Microsoft Office\Office10\excel.exe" /automation -Embedding

I only want to kill those excel automation objects and ps can help me distinguish the excel runtimes I created via Start menu and those via COM calls.

How can I show the /automation -Embedding bit in the powershell?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Get-Process doesn't return the command line information, but the WMI class Win32_Process does. To use WMI classes, use the Get-WMIObject cmdlet which has the alias gwmi.

To kill all excel automation objects, you could use:

gwmi Win32_Process -filter "Name='Excel.exe'"| 
    where { $_.CommandLine -match '/automation -Embedding' }|
    foreach { $_.Terminate() }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.