Process.GetProcesses() as Non-Admin

Update: Thanks to Kevin Driedger and Arild Fines for pointing out the pitfalls of using 'tasklist.exe' on Win2k.  On Win2k it is called 'tlist.exe' and is apparently an optinal component.  In the end Trey Hutcheson saved the day by giving me the PInvoke code I needed (thanks Trey!!).  It will work on all platforms now, for admins and regular users.

I posted yesterday that I've been experiencing strange exceptions when using the 'System.Diagnostics.Process' class. It turns out this class it a bit of a mine field and there is a lot that can go wrong with it. With an inspired bit of lateral thinking, Peli suggested I parse the output of 'tasklist.exe'. The advantages being; it works for non-admin users, it takes a fraction of a second to execute and it doesn't cause the floppy drive to light up (see #2 here). I've uploaded a new version to the AutomatedBuilds page. If you get a chance to try it and/or experience any problems, could you let me know?  BTW, you can install and run TestDriven.NET as a non-admin user. I maybe forgot to mention this. ;o)

4 Comments

Comments have been disabled for this content.