Recent

Author Topic: Run program in Windows 7 UAC (User Account Control)  (Read 16310 times)

tuxmartin

  • New member
  • *
  • Posts: 8
Run program in Windows 7 UAC (User Account Control)
« on: October 16, 2011, 11:16:18 am »
I need to execute external application from program in Windows7. If I disable UAC (User Account Control) it works.
When UAC is enabled, it doesn't work. :-(
How can I "run as admin" ?

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  app: TProcess;
begin
   app := TProcess.Create(nil);
   app.CommandLine := 'certutil -addstore -f Root "cert.crt"';
   app.Execute;
   app.Free;
end;

lainz

  • Guest
Re: Run program in Windows 7 UAC (User Account Control)
« Reply #1 on: October 16, 2011, 03:45:05 pm »
If you run your program with UAC enabled, but you run as administrator (right click > run as administrator) works?

If works the only thing you need to do is change the manifest:

<requestedExecutionLevel level="asInvoker" uiAccess="false"/>

requestedExecutionLevel in Vista can be:

* asInvoker
* highestAvailable
* requireAdministrator

In order to change the manifest you must uncheck in project options the 'Enable Themes' and 'DPI aware application'. And load the manifest from a resource file. Read here:

http://lazarus.freepascal.org/index.php/topic,11659.msg69861.html

seier

  • New Member
  • *
  • Posts: 11
Re: Run program in Windows 7 UAC (User Account Control)
« Reply #2 on: August 28, 2012, 09:58:36 pm »
In Lazarus 1.0 do the following:
  • Click "Project" --> "Project Options"
  • In the "Execution Level" drop down list box select "require administrator"
  • Click [Ok]

 

TinyPortal © 2005-2018