I run on the machine as admin, but with the UAC set to default mode.
I start an installation program (using “Run as administrator”). From the installation process (using Wix) I start a client program that creates some files on the disc (C:\ProgramData…).
var startInfo = new ProcessStartInfo()
{
WorkingDirectory = installLocation,
FileName = fullPath
};
Process.Start(startInfo);
This first time the program runs, I can access all the data stored on the local disc without problems.
If I close it and start it again, I receive this error message:
Access to the path ‘C:\ProgramData…’ is denied.
If I start again the application using “Run as administrator” I can access the files from local disc; no error this time. The access path error appears only when I start the application directly.
Is this due to the settings from UAC or it is related that the local files where created under a more privileged user account?
Yes, the application will run without elevated privileges which are required to access ProgramData and other sensitive system folders or user related folders.
Any process you spawn from within your application
will inheritthe privileges your application has.You need to create a manifest for your application to request elevated rights upon starting so you will have access to those folders.