Home

Access Rights Linqpad

edited September 2016
Hi everyone,
I have a simple question. The following code runs in LINQPad without admin rights. If I start the same code from a simple console application I get access rights exceptions.

Any hint?

void Main() { var processList = Process.GetProcesses(); foreach(var process in processList) try { GetCommandLine(process).Dump(); Console.WriteLine(); } catch (Win32Exception ex) { if ((uint)ex.ErrorCode != 0x80004005) { throw; } } } // Define other methods and classes here private static string GetCommandLine(Process process) { var commandLine = new StringBuilder(process.MainModule.FileName + " "); using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id)) { foreach (var @object in searcher.Get()) { commandLine.Append(@object["CommandLine"] + " "); } } return commandLine.ToString(); }

Comments

Sign In or Register to comment.