banks Posted July 25, 2012 Report Posted July 25, 2012 Salut doresc sa inchid toate procesele cu numele notepad de exemplu dar doar din userul activ. foreach (System.Diagnostics.Process myProc in System.Diagnostics.Process.GetProcesses()) { if (myProc.ProcessName == "notepad" ) { myProc.Kill(); } }Daca folosesc ce am scris mai sus , daca am notepad deschis in oricare user se va termina procesul..Eu doresc sa se termine procesul doar din userul curent..cum trebuie sa fac? Quote
SirGod Posted July 25, 2012 Report Posted July 25, 2012 Mai baga o conditie in IF. Vezi daca utilizatorul curent e cel pe care il "vrei".how to get current username in .net using c#? - Stack OverflowSau:How do you kill a process for a particular user in .NET (C#)? - Stack Overflow Quote
banks Posted July 25, 2012 Author Report Posted July 25, 2012 Mai baga o conditie in IF. Vezi daca utilizatorul curent e cel pe care il "vrei".how to get current username in .net using c#? - Stack OverflowSau:How do you kill a process for a particular user in .NET (C#)? - Stack OverflowDaca pun un if cu userul activ va face asa:Cauta numele userului activ sa zicem Ion.foreach (System.Diagnostics.Process myProc in System.Diagnostics.Process.GetProcesses()){if (myProc.ProcessName == "notepad" && numele activ=="ion" ){myProc.Kill();}}Se va inchide notepad peste totpentru ca cel activ este ion..deci nu ajuta..cat despre linkurile care le-ai dat acum le incerc, mersi mult pentru ele. Quote
zorro59 Posted July 27, 2012 Report Posted July 27, 2012 (edited) How do I determine the owner of a process in C#? - Stack Overflowhttp://stackoverflow.com/questions/300449/how-do-you-get-the-username-of-the-owner-of-a-processIa vezi daca asa ceva iti trebuie Edited July 27, 2012 by zorro59 Quote