title: Is possible to get full file name of a process for which I have no permissions?
body: <p>When new updates are available, my Delphi application counts processes running from the same directory. If it finds the current process only, then it downloads the updates and restarts itself.</p>
  
  <p>For counting processes by full file name, I'm using <code>OpenProcess</code> and <code>GetModuleFileNameEx</code> as shown in <a href="https://stackoverflow.com/questions/40404309/how-to-count-processes-starting-from-a-full-file-name">this question</a>.</p>
  
  <p>In most cases, everything works but one of my customers uses thin clients and a server in which the application is installed in several directories (Each user has its own installation folder on the server).</p>
  
  <p>When an user starts the application from his thin client, the application finds also the processes that belongs to other users but it can't obtain the executable full file name because <code>OpenProcess</code> causes an <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx" rel="nofollow noreferrer">access denied error</a>:</p>
  
  <blockquote>
    <p>ERROR_ACCESS_DENIED</p>
    
    <p>5 (0x5)</p>
    
    <p>Access is denied.</p>
  </blockquote>
  
  <p>Here is how I'm calling <code>OpenProcess</code> and <code>GetModuleFileNameEx</code>:</p>
  
  <pre><code>const
    S_PROCESS_QUERY_LIMITED_INFORMATION = $1000;
  
  function GetFullFileNameFromPID(const PID: Cardinal) : string;
  var
    ProcessHandle : THandle;
    Path : array[0..MAX_PATH - 1] of Char;
  begin
    ProcessHandle := OpenProcess(S_PROCESS_QUERY_LIMITED_INFORMATION, False, PID);
    if(ProcessHandle &lt;&gt; 0) then
    begin
      if(GetModuleFileNameEx(ProcessHandle, 0, Result, MAX_PATH) = 0)
      then RaiseLastOSError
      else Result := Path;
  
      CloseHandle(ProcessHandle);
    end else
      RaiseLastOSError;
  end;
  </code></pre>
  
  <p>Is there a way to get this information from a process for which the application have no permissions?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>The filename is not enough for my purpose, I noticed that I can get the full file name using Task manager with the same user who gets ERROR_ACCESS_DENIED but I don't understand how it is obtaining that information.</p>
  
  <p><a href="https://i.stack.imgur.com/MlsMM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MlsMM.png" alt="enter image description here"></a></p>