2
Is there any way that I can get a process that’s running under a partial name, like what happens to like
in a survey SQL
?
'Cause I ask this, I got one team viewer
customized here for the company. Only that the version we have here is the 10. Beauty so far without problems... What happens is that if you happen to have a process named "Team Viewer 10", I can kill he. Only if the client has a newer or earlier version, the name of the process is not the same... Then there would be no way kill.
So there’s a way I could take the name of the lawsuit in a partial way and if found, kill? That is, if I find a process with the name "Team Viewer", already trigger the code to kill that process?
What I have so far:
//buscando o nome do processo
System.Diagnostics.Process[] processoTv = System.Diagnostics.Process.GetProcessesByName(teamViewer);
//verificando se existe o processo em execução e se houver finaliza
if (processoTv.Length > 0)
foreach (System.Diagnostics.Process processoItem in processoTv)
processoItem.Kill();
Where teamViewer
is equal to "Team Viewer 10".
Is there any way to do that?
Process[] processoTv = Process.GetProcesses(); //variável só necessária se pretente usar mais tarde
.... Later how? Like if I want to check the processes running at some point?– Érik Thiago
Variable should essentially be used to create an intermediate state. Although it may be useful to create a variable to use only once, in general, this is not necessary. Of course, if something is too complicated, it’s good to create a variable just to document, but it’s rare. If you’re going to use that only once in the algorithm, don’t create a variable just for that, use the direct expression. Most programmers do not understand the use of the variable, which is one of the most basic features of code. The problem may be the examples that to be didactic put redundancy. It is not to copy.
– Maniero
I managed to solve using your solution! Thank you very much!
– Érik Thiago