PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Identifying a process so that it can be killed
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Identifying a process so that it can be killed
![]() |
Identifying a process so that it can be killed |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 BOPMKR wrote: > 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 > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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" <sergey.bogdanov@gmail.com> wrote in message news:ebzCEmcQGHA.3804@TK2MSFTNGP15.phx.gbl... > 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 > > > BOPMKR wrote: >> 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 >> |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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" wrote: > 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 > > > BOPMKR wrote: > > 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 > > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Thanks Paul I will look into this as well.
"Paul G. Tobey [eMVP]" wrote: > 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" <sergey.bogdanov@gmail.com> wrote in message > news:ebzCEmcQGHA.3804@TK2MSFTNGP15.phx.gbl... > > 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 > > > > > > BOPMKR wrote: > >> 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 > >> > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

