Killing Ghost Excel processes

zealot777

Board Regular
Joined
Nov 9, 2006
Messages
135
Hi,
I am running a macro in Matlab which leaves the 5 ghosts excel.exe processes running after each macro loop - I have 168 loops - so it builds up a lot.I wanted to ask if there is a way to close all instances of excel.exe - other than the active master workbook from which the macros are running?Or excel processes can be differentiated by size (less than 100 lbs) or less than minute older.
Thanks a hope it is possible!
Dave
 
Last edited:

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,804
Office Version
  1. 365
Platform
  1. Windows
Dave

Have you checked why you are ending up with ghost processes?
 

zealot777

Board Regular
Joined
Nov 9, 2006
Messages
135

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,804
Office Version
  1. 365
Platform
  1. Windows
Dave

I can post some Powershell code to kill all Excel processes, is that the sort of thing you are looking for?
 

zealot777

Board Regular
Joined
Nov 9, 2006
Messages
135

ADVERTISEMENT

Dave

I can post some Powershell code to kill all Excel processes, is that the sort of thing you are looking for?

sweet - can i envoke this code from vba? and kill only processes smaller than 100 mbs? that woudl be perfect!
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,804
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Sorry, not had time to reply - actually thought I had some code kicking about but I can't find it.

I'll try and post something later.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,804
Office Version
  1. 365
Platform
  1. Windows
Here's PowerShell code that will kill any Excel processes that are using less than 10MB.
Code:
$processes_to_kill = get-process |

    where { $_.PM -le 10MB  -and $_.path -like "*excel.exe"}

if ($processes_to_kill -ne $null)

{

    $processes_to_kill | foreach { $_.Kill() }

}
 

Watch MrExcel Video

Forum statistics

Threads
1,108,501
Messages
5,523,293
Members
409,508
Latest member
Afc

This Week's Hot Topics

Top