On Wed, Jun 16, 2021 at 2:26 PM Jean SUZINEAU via fpc-pascal
<fpc-pascal@lists.freepascal.org> wrote:

> I think there is a way to do this with a single program.

Using Lazarus IDE I tried to set Execution level to
"requireAdministrator", but then the program simply would not run (it
would not ask for the admin password), so in the end I just used
something like:

uses
  WinUtils;

procedure CheckIsAdmin;
begin
  if not WinUtils.IsWindowsAdmin then
  begin
    writeln('This program requires administrator priviliges.');
    writeln;
    Halt;
  end;
end;

Bart


-- 
Bart
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to