Identifying a process so that it can be killed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following vb code will identify that mstsc.exe is actually running, but I
can't find a way to kill it. I've searched google groups etc. but no luck so
far. It does seem though, that a lot of people are lookig for an answer to
this.
--------------------------------------------------------
Imports OpenNETCF.ToolHelp

Dim pe()
Dim p As Process

pe = ProcessEntry.GetProcesses()

For i = 0 To UBound(pe)

If pe(i).ToString = "mstsc40.exe" Then '... this works

p = Process.GetProcessById(i) ' .... this doesn't work
p.Kill() ' ..................................... so nor
does this

End If
Next i
 
What about pe(i).ProcessID to get ProcessID and in your case it should
something like this:

For i = 0 To UBound(pe)
If pe(i).ToString = "mstsc40.exe" Then
pe(i).Kill()
End If
Next i
 
But you really should try closing it in a more-friendly manner than just
terminating it. Try sending WM_CLOSE to its main window, for example, and
maybe trying to send WM_QUIT to its main thread. If that doesn't work in a
few seconds, you can kill the process on the assumption that it's locked up.

Paul T.

Sergey Bogdanov said:
What about pe(i).ProcessID to get ProcessID and in your case it should
something like this:

For i = 0 To UBound(pe)
If pe(i).ToString = "mstsc40.exe" Then
pe(i).Kill()
End If
Next i


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

The following vb code will identify that mstsc.exe is actually running,
but I can't find a way to kill it. I've searched google groups etc. but
no luck so far. It does seem though, that a lot of people are lookig for
an answer to this.
--------------------------------------------------------
Imports OpenNETCF.ToolHelp

Dim pe()
Dim p As Process

pe = ProcessEntry.GetProcesses()
For i = 0 To UBound(pe)

If pe(i).ToString = "mstsc40.exe" Then '... this works

p = Process.GetProcessById(i) ' .... this doesn't work
p.Kill() ' ..................................... so
nor does this

End If
Next i
--------------------------------------------------------
Of course (i) is not the real process ID, the question is how do I find
the real process ID for the instance of mstsc40.exe??

Thanks in advance
 
Thanks
This failed with a no late binding error until I changed the
pe() definition from:

Dim pe()

to

Dim pe() As ProcessEntry

Sergey Bogdanov said:
What about pe(i).ProcessID to get ProcessID and in your case it should
something like this:

For i = 0 To UBound(pe)
If pe(i).ToString = "mstsc40.exe" Then
pe(i).Kill()
End If
Next i


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

The following vb code will identify that mstsc.exe is actually running, but I
can't find a way to kill it. I've searched google groups etc. but no luck so
far. It does seem though, that a lot of people are lookig for an answer to
this.
--------------------------------------------------------
Imports OpenNETCF.ToolHelp

Dim pe()
Dim p As Process

pe = ProcessEntry.GetProcesses()

For i = 0 To UBound(pe)

If pe(i).ToString = "mstsc40.exe" Then '... this works

p = Process.GetProcessById(i) ' .... this doesn't work
p.Kill() ' ..................................... so nor
does this

End If
Next i
--------------------------------------------------------
Of course (i) is not the real process ID, the question is how do I find the
real process ID for the instance of mstsc40.exe??

Thanks in advance
 
Thanks Paul I will look into this as well.

Paul G. Tobey said:
But you really should try closing it in a more-friendly manner than just
terminating it. Try sending WM_CLOSE to its main window, for example, and
maybe trying to send WM_QUIT to its main thread. If that doesn't work in a
few seconds, you can kill the process on the assumption that it's locked up.

Paul T.

Sergey Bogdanov said:
What about pe(i).ProcessID to get ProcessID and in your case it should
something like this:

For i = 0 To UBound(pe)
If pe(i).ToString = "mstsc40.exe" Then
pe(i).Kill()
End If
Next i


--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

The following vb code will identify that mstsc.exe is actually running,
but I can't find a way to kill it. I've searched google groups etc. but
no luck so far. It does seem though, that a lot of people are lookig for
an answer to this.
--------------------------------------------------------
Imports OpenNETCF.ToolHelp

Dim pe()
Dim p As Process

pe = ProcessEntry.GetProcesses()
For i = 0 To UBound(pe)

If pe(i).ToString = "mstsc40.exe" Then '... this works

p = Process.GetProcessById(i) ' .... this doesn't work
p.Kill() ' ..................................... so
nor does this

End If
Next i
--------------------------------------------------------
Of course (i) is not the real process ID, the question is how do I find
the real process ID for the instance of mstsc40.exe??

Thanks in advance
 
Back
Top