thkr
Posts: 13
Joined: Tue Aug 25, 2015 9:55 am

Access Denied in C# Custom Action

Hello,

i have a Setup Project which contains .NET C# Custom Actions. One of these Custom Actions try to start a Process (which needs admin rights).
The "Execution Time" of the custom action is after the system has been successfully modified (commit).
With execute option no impersonation, run with full local system privileges.

If the location of the program which i want to start in the custom action is in a local system folder, everything is ok.
But if the location (its possible) is in a shared folder the ProcessStart fails with "Access Denied".
If i change the execution time to "Immediately", the process starts without errors, even it is in a shared folder.

Dont know if this helps, ProcessStartInfo object i use:

Code: Select all

new ProcessStartInfo
            {
                FileName = process,
                Arguments = arguments,
                UseShellExecute = true,
                RedirectStandardError = false,
                RedirectStandardInput = false,
                RedirectStandardOutput = false,
                ErrorDialog = false,
                Verb = "runas"
            };
Thanks.
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Access Denied in C# Custom Action

Hello and welcome to our forums,

This happens because, by default, the "LocalSystem" account doesn't have access rights on network shared locations. So, when you run the custom action with no impersonation you won't be able to access the related network location.

As a workaround you should add proper permissions on the related network shared location (e.g. Everyone -> Full Control).

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
thkr
Posts: 13
Joined: Tue Aug 25, 2015 9:55 am

Re: Access Denied in C# Custom Action

Hello Daniel,

you are right. The LocalSystem account doesn't have access rights on network shared locations.
I removed the "no impersonation" option and require now admin permissions on the process that i want to start.

In this case the process got the admin rights and it works properly. Thanks!
Daniel
Posts: 8276
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Access Denied in C# Custom Action

You're welcome. I'm glad you got this working.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”