0

I have a problem with the installation of the service.

I do it by default shortcut and a postscript or /install /uninstall depending on the need . Unfortunately, the program generates an error to stop the action .

Amazingly installation work properly on older environments.

Is there any other way to install the service?

whosrdaddy
  • 11,720
  • 4
  • 50
  • 99
Toster
  • 361
  • 3
  • 17

3 Answers3

2

The installation worked on older environments when UAC is turned off (which is a bad thing to do), you always need to run your installation program/script with elevated privileges (it has been like this since Windows Vista). You can include a manifest so that your application/service requires elevation when executing with /install parameter.

To include a manifest, you need to create an xml file called manifest.xml with following contents:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="YourApplication.exe" type="*" />
  <description>elevate execution level</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*" />
    </dependentAssembly>
  </dependency>
</assembly>

Then create a file called manifest.rc with following content:

1 24 "Manifest.xml"

In modern Delphi versions, you can just include the rc file in the project via the project manager and Delphi will automatically include it as a resource. In older Delphi versions you need to manually compile the .rc file with brcc compiler to produce the .res file.

whosrdaddy
  • 11,720
  • 4
  • 50
  • 99
  • Delphi 10 Seattle (XE10) – Toster May 31 '16 at 09:05
  • 1
    @Toster - have you google a little bit about including a manifest in a Delphi application? whosrdaddy has given you exactly what to do. – RBA May 31 '16 at 09:09
  • Believe me I tried to look , but there is a large discrepancy response . If @whosrdaddy is oriented in the subject may I suggest a quick hint answer . – Toster May 31 '16 at 09:16
  • 1
    @Toster this is all over 10 years old. You simply must do some research so that you understand UAC. – David Heffernan May 31 '16 at 16:41
  • If you add a UAC elevation manifest to the service executable itself then the service will run elevated regardless of whether it is being (un)installed or actually run. What you SHOULD be doing is applying the manifest to whatever app/script is performing the (un)install (or just run the app/script elevated to begin with without a manifest), instead of applying the manifest to the service itself. Let the service run in whatever user account you configure the service to run as. – Remy Lebeau Jun 01 '16 at 00:12
1

Have you try to run as administrator? Maybe it is a permission problem.

Marco
  • 47
  • 4
  • Yes, but if i have permission problem on Windows 7 and older i don't get error (like Program xxx stop working), just a permission problem error (code 5). On Windows 10 just just (Program xxx stop working) – Toster May 31 '16 at 07:22
  • Perhaps program doesn't support win 10, what program is it? – Marco May 31 '16 at 07:52
  • The program is okay ( Delphi compiled service ) but the problem is only with the installation. – Toster May 31 '16 at 08:03
0

In modern Delphi versions : no need .rc Go to Menu : Project > Options > Application > Manifest File : - AutoGenerate - RequireAdminstrator

Best regards.

Zerrouki
  • 1
  • 1