Run application via delphi service with admin rights

0

I need to run an application through service with delphi with elevated administrator rights.

I have tried several solutions found here, such as

RunAsAdminAndWaitForCompletion(filename,
  Parameters: string; wait: boolean): Boolean;

However the application when run by the service, does not have administrator rights.

A simple impression by the application that was called is not executed because the calling application has no access to the peripherals. How can I make the application running through the service run with admin privileges on the machine.

The user who is logged in to the machine is already an administrator.

    
asked by anonymous 03.02.2017 / 17:44

1 answer

0

Man, I was giving a quick search and found it here:

uses ShellApi;

ShellExecute(Handle, 'runas', 'regedit', nil, nil, SW_SHOWNORMAL);

I tested here in Delphi XE5 with a common application and it worked fine (I put a button on the form and click it I put this command), you can see that the command I'm calling is Regedit and this face is only opened with admin permission.

Hug.

    
11.05.2017 / 08:46