سؤال

I have found following issue with a CLI tool that accepts files via drag'n'drop.

The file X:\MyApp.exe is a CLI tool which requires UAC elevation (which will be granted).

The operating system is Win7 32-bit.

X: is a network drive to a NAS.

When I drag X:\MyDLL.dll into X:\MyApp.exe , FileExists(ParamStr(1)) will be false. RaiseLastOSError() will show code 3. What am I doing wrong?

It does work when the source file is stored at C: (and dragged into the EXE file).

WriteLn('ParamStr 1 = '+ParamStr(1)); // X:\MyDLL.dll
if not FileExists(ParamStr(1)) then
begin
  try
    RaiseLastOSError;
  except
    on E: exception do
    begin
      Writeln(E.message); // (Translated) System error 3. The file could not be found.
    end;
  end;
  exit;
end;
هل كانت مفيدة؟

المحلول

An elevated application does see the mapped drives for the user. This is similar to a service logging in under a user account and the user logging into the desktop with the same user account. The service won't be able to see the user's mapped drives.

A work around for this type of situation is to create a service that runs with the permissions you require and then a standard application that runs non-elevated. The application sends messages to the service so that it can perform the actions that need elevation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top