No need to fiddle with the path. Just launch Visual Studio from the Developer Command Prompt:
"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe"
Configure VS Code for Microsoft C++