faizanmanzoor123
Posts: 6
Joined: Fri Mar 08, 2019 9:34 am

RSA Protected Configuration Provider

HI

I encrypt the config file with " aspnet_regiis.exe " command by running the batch file through custom action as Administrator.
Above command encrypt my config file but when i run the Application it gives me Error "RSA Protected Configuration Provider". When I run same application as " Run as Administrator" Application runs fine.

Error is attached.

How I give permission to my current user or Application file to run as administrator by default.

TIA
Attachments
encrypt.png
encrypt.png (80.09 KiB) Viewed 5319 times
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: RSA Protected Configuration Provider

Hello,

Manually, this can be achieved by right clicking on the EXE --> "Properties" --> "Compatibility" tab --> "Run this program as an administrator" option.

However, in order to achieve this programmatically, we will need to make use of the following registry key:

Code: Select all

HKCU:\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
Here is a PowerShell script which will do what you want:

Code: Select all

$runAsAdminReg = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
$name = "C:\Users\Catalin\Desktop\sample.exe"
$value = "RUNASADMIN"
New-ItemProperty -Path $runAsAdminReg -Name $name -Value $value -PropertyType string -Force | Out-Null
This can be added in your project as a "PowerShellInlineScript" custom action. The custom action should be scheduled after the "Add resources" action group, on deferred. This is due to the fact that during the "Add resources" action group, the files are copied over to the target machine (your config file). Also, since you are bringing modification to the registries, the setup should run as administrator.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
faizanmanzoor123
Posts: 6
Joined: Fri Mar 08, 2019 9:34 am

Re: RSA Protected Configuration Provider

Thanks for the Response.

I already apply this technique. It works fine 1 machine but on other machine it generate the same error. Even if I run the exe as Administrator.
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: RSA Protected Configuration Provider

Hello,
It works fine 1 machine but on other machine it generate the same error.
Could you please give me some more details about this? On which machine does it work and on which it does not (for instance, have you tested it on a different OS?)?

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
faizanmanzoor123
Posts: 6
Joined: Fri Mar 08, 2019 9:34 am

Re: RSA Protected Configuration Provider

Hi
Thanks for the response.

Both machine have same OS window 10.
Catalin
Posts: 7845
Joined: Wed Jun 13, 2018 7:49 am

Re: RSA Protected Configuration Provider

Hello,

This is, indeed, strange. I can not say for sure why this happens.

In order for me to further investigate this, could you please send me a download link for the setup that reproduces this and also the .AIP file that was used to build the setup by e-mail at support at advancedinstaller dot com so I can test it on our end?

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”