Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One of my office PC fails to find MSVC when not running in elevated terminal. #310

Open
solarispika opened this issue Mar 26, 2024 · 6 comments

Comments

@solarispika
Copy link

I have tried reinstall MSVC 2019/2022, but it doesn't work.
I have to always run vscode/vs installer as administrator in order to use MSVC.
My user account is already in administrators group.
Could it be some components owned by some administrator and not readable by others?

@heaths
Copy link
Member

heaths commented Mar 26, 2024

What command are you running? What channel did you install? Note that prereleases and incomplete installs are not shown by default. Running vswhere -help will give you more details.

@solarispika
Copy link
Author

Hi @heaths
I have tested with latest version of vswhere.
image
I'm not using prereleases or buildtools.

@heaths
Copy link
Member

heaths commented Mar 27, 2024

If the same command works as administrator, it seems you have an atypical permissions issue on %ProgramData%. Install Process Monitor, run that to collect a trace, filter by the process name vswhere, export only the unfiltered results, zip, and attach them here.

Alternative, though it may not be as helpful, run the following in an elevated command prompt:

cmd

icacls "%ProgramData%\Microsoft\VisualStudio\Packages\_Instances"

or

powershell

icacls "${env:ProgramData}\Microsoft\VisualStudio\Packages\_Instances"

/cc @tydunkel

@solarispika
Copy link
Author

I ran the powershell but problem still exists.
Here's the problem trace: Logfile.zip

@heaths
Copy link
Member

heaths commented Mar 28, 2024

Thanks. As I suspected, you're getting an ERROR_ACCESS_DENIED trying to read/list the directory above. icacls should've produced output if you run it elevated, which will help diagnose the problem and suggest a fix. Please paste it in a reply.

Normally, %ProgramData% has read/list (RX) permissions for Everyone, but it seems that's not the case for you or that it has an integrity level higher than normal - allowing only elevated access. icacls will show us that.

@solarispika
Copy link
Author

Thank you for the information, I managed to recover the permission of the mentioned folder.

The original output of the command is

 pika1  icacls "${env:ProgramData}\Microsoft\VisualStudio\Packages\_Instances"
C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances BUILTIN\Administrators:(F)
                                                          BUILTIN\Administrators:(I)(OI)(IO)(F)
                                                          BUILTIN\Administrators:(I)(CI)(F)

And I replaced all child object permission entries of ${env:ProgramData}\Microsoft\VisualStudio
image

And it became

 pika1  icacls "${env:ProgramData}\Microsoft\VisualStudio\Packages\_Instances"
C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances Everyone:(I)(OI)(CI)(M)
                                                          BUILTIN\Users:(I)(OI)(CI)(M)
                                                          NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
                                                          BUILTIN\Administrators:(I)(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

And I can access MSVC without administrator privileges!

Here's a question: Is it possible to show some error messages about why it can't find usable MSVC?
In this case, yelling permission error on the folder maybe helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants