How to get the user/owner name of a process in vb.net???

Could anybody tell me
How to get the user/owner name of a process in vb.net

The reason I need it is because I developed an application,
which I will put on the winnt enviroment, I want to allow multiple instance.
but only allow one single instance per user.

I am using Application.Run(MyMainForm) to start my application

Thanks,
Joseph



Answer this question

How to get the user/owner name of a process in vb.net???

  • mattcushing

    Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)

    need to get the username of exisiting process.

    so can't use ProcessStartInfo.UserName
    Or Environment.UserName.


    I came up with put the Environment.UserName into the mainWindows Title
    and then fetch the Process.MainWindowsTitle.


    Joseph


  • vj78

    That's good to know!

    That's desirable behavior sometimes and sometimes undesireable. I wish there were a way to specify which behavior would occur.

    Btw, I NGENed for the first time Thursday. Where I was filled with trepidation at first, I found that the documentation was very good and the whole thing went quite easily. Subjectively, the project seems more responsive and it works very well.

    Thank you for that pointer.

    Renee

  • rlasker3

    Johan,

    The opposite is being requested. Multiple instances in a system but only a single instance per user.

  • Krishna Samaga

    If you happen to be using Visual Studio 2005, you can go to project properties (double-click My Project in the solution explorer) and check the "Make single instance application"

    Best regards,
    Johan Stenberg

  • Pavithra

    I'm glad you had a positive experience with NGEN Smile.

    I just wanted to confirm that you do indeed get a single instance per login (my >90% hunch was correct)

    Best regards,
    Johan Stenberg

  • frankbel

    To get the username of the current running process

    System.Diagnostics.ProcessStartInfo.UserName

    or

    System.Environment.UserName

  • Kevinmi

    "Single instance" should be read as "Single instance per user" - see http://msdn2.microsoft.com/8fz4ssw2

    I'm >90% sure that the behavior when multiple users are logged on to the same box is to allow each user to run exactly ony instance...

    I can double-check this when I'm back in the office on Monday...

    Best regards,
    Johan Stenberg

  • How to get the user/owner name of a process in vb.net???