Run application through Delphi service with administrator rights

Asked

Viewed 910 times

1

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

I have tried several solutions found here, such as

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

However the application when it is executed by the service, is without administrator rights.

A simple print by the calling application is not executed, because the calling application has no access to the peripherals. How can I get the application running through the service to run with administrator privileges on the machine.

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

1 answer

1

Man, I was doing a quick search and I found this here:

uses ShellApi;

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

I tested here on Delphi XE5 with a common application and it worked right (I put a button on the form and on click from him I put this command), you can see that the command I am calling is the Regedit and this little guy is only open with admin permission.

Give a tested there in your case to see if it solves your problem, anything comments there that we go talking.

Hug.

  • I used Delphi XE5 in a VCL project - Forms Application, I don’t know what version of Delphi you are using there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.