kill a process in task manager only for a certain user name

Posted on 2006-04-07
Last Modified: 2013-12-03
Hello experts,

Is there a way to get the user who owns the process in the Process[] collection retrieved by Process.GetProcessByName("ANYNAME")?

I see more than one instance and I only want to kill the process that belongs to a specific user. The server is a terminal server by the way. Thanks in advance,

Alpha Guys
Question by:AlphaGuys
    LVL 7

    Expert Comment

    Someone already answered this more or less:
    LVL 30

    Accepted Solution

    LVL 1

    Expert Comment


    If u r running Windows XP, simply use
     TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"

    Goto Command Prompt and type "TASKKILL /?" which will kill the exact Process for that user on ur local box or any remote machine, provided the user logged in has Admin privilage on the remote or local box because thats under OS Kernal. :-)

    In another OS, i guess just copying the TASKKILL from windows XP to target OS is sufficient. Not 2 sure abt it.


    Author Comment

    Thanks for the answers guys, looks like Alex pointed out a good link. My application runs on a terminal server (WIN2k3server) and a number of users can log on and run my application. My main concern is the hanging Office and sometimes Adobe applications. I would like to kill those processes(EXCEL.EXE, WINWORD.EXE, etc) from my application but only for the user who is running that application. I will try out Alex's link and see if I can do it even with the users just having limited permissions. Thanks again for all your help!

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now