Process[] processlist = Process.GetProcesses();
foreach (Process proc in processlist) {
Console.Write(proc.MainModule.FileName);
}
it giv
There are some processes that you aren't allowed to access even as administrator. You can trap the exception and keep going:
foreach (Process proc in processlist)
{
try
{
Console.WriteLine(proc.MainModule.FileName);
}
catch (Win32Exception e)
{
Console.WriteLine(proc.ToString() + " " + e.Message);
}
}