Add-on components that enhance and customize the Visual Studio integrated development environment
I've faced the same issue but for my case the issue was related to company policy related to registry edits. It's blocked, but it's seems to be very excessive as it also blocks any READS of the registry.
For me the problem is that my company policy is blocking registry queries like "reg query" for getting values from the registry. The C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Tools\vsdevcmd\core\winsdk.bat file uses this command to determine and set specific environment variables. If those environment variables are not set, then VSCode will not be able to properly setup the environment. As a workaround I've replaced the "req query" calls with the powershell equivalent in the winsdk.bat file (AI is your friend). Luckily using powershell it is allowed to read the registry according to my companies policies. After making those changes and then in VSCode do Ctrl+Shift+P " C/C++: Clear Visual Studio Developer Environment" and then Ctrl+Shift+P "C/C++: Set Visual Studio Developer Environment" it started to work.
To assert if this fix will work for you, just try to run "REG QUERY HKLM\Software\Microsoft\ResKit /v Version". If you get "ERROR: Registry editing has been disabled by your administrator." then the above solution should work.
This is a workaround and in my opinion MS should update the winsdk.bat (as well as the dotnet.bat) to use Powershell instead of "reg query" to query the registry.