
Originally Posted by
l33t_c0w
If I kill it there seem to be no ill effects and then everything runs well, but that isn't an option unless I can be sure that I'm killing the right process.
Here is how you can kill the right process.
First, after you started the Excel process that you want to kill (the first one I think) call this function
VB Code:
Declare Function GetCurrentProcessId Lib "kernel32" () As Long
This function return the process ID of the Excel process just created.
Put the result in a variable
Once you have done everything you want to do and want to kill the god dam process
do
VB Code:
Function KillPId()
Set ProcessList = GetObject("winmgmts://.").InstancesOf("win32_process")
For Each Process In ProcessList
If Process.ProcessID = variable Then ' variable = the processID obtain by the GetCurrentProcessId function
Process.Terminate
End If
Next
End Function
Hope it will helps a bit