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:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,343
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
76,343
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
76,343
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
76,343
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() }

}
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,699
Messages
5,833,206
Members
430,196
Latest member
rez5656

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top