Acces is denied

Lambert, Mark (US) - ISR 21 Reputation points

After an update to Visual Studio Pro (V 16.11.11), I am no longer able to execute this simple snippet of code:


I now get this error:


What do I now need to do to prevent this error. Previous versions did not generate this errors. I have admin privilege on my machine to I should not get this error.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,715 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,408 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,201 Reputation points



    And this will work also

    var p = new Process { StartInfo = new ProcessStartInfo("C:\\Users\\paynek\\Documents") { UseShellExecute = true } };

    I'd go with the first simply because there is less code and we get the same outcome.

1 additional answer

Sort by: Most helpful
  1. RLWA32 41,206 Reputation points

    Explorer is a single-instance application. Attempts to start a second instance just hand-off the requested action to the already running instance. So the instance of explorer that attempts to open the file system folder that belongs to a different user is made by the process that is running as the logged-on user. Even when the logged-on user is a member of the Administrators group explorer is running with a filtered token that does not contain elevated privileges. And running the code in an elevated process doesn't change anything. The result is the same -- the explorer process that attempts the folder access is running without elevated privilege so the attempt to open a different accounts profile folders fails with access denied.

    See Explorer is a single-instance application, but you can find other ways to get the effect of running a separate instance

    1 person found this answer helpful.
    0 comments No comments