Jump to content
banks

c# kill procces in userul de windows activ

Recommended Posts

Posted

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?

Posted

Daca 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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...