Visual Studio 2022 missing environment variables?

Mark Weiss 71 Reputation points
2025-03-16T18:41:58.78+00:00

I installed Visual Studio 2022 originally so I could run Zonos text to speech. That's working fine.

I even was able to follow some coding tutorials and compile some C++ and C# apps.

However, when I run a batch file that is to compile an app, it seems not to be able to find Visual Studio and or some of its components.

I have no idea how to fix this.

User's image

Developer technologies Visual Studio Debugging
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 49,461 Reputation points
    2025-03-16T19:36:33.13+00:00

    First open a Visual Studio Developer command prompt. It will setup what is needed for using command line tools. There should be a shortcut in the start menu for it. Then run your batch file.


  2. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2025-03-17T11:06:05.66+00:00

    Hi @Mark Weiss ,

    I doubt that some or one certain path are/is not configured correctly on your machine.

    Please make sure that the VsDevCmd.bat file exists in C:\Program Files\Microsoft Visual Studio\2022<edition>\Common7\Tools folder. Run CMD as administrator, and then run following commands:

    set VSCMD_DEBUG=1

    "C:\Program Files\Microsoft Visual Studio\2022\<edition>\Common7\Tools\VsDevCmd.bat"

    After that, check the detailed output message.

    User's image

    Just for example, if you find an error messages like "Could not find directory …"(missing a backslash in the path).

    You can then search "Edit the system environment variables" in Windows Search box, open it and click Environment Variables button, in System variables box, select Path, click Edit button, add the correct path into it.

    User's image

    Besides, I suggest you also try to repair Visual Studio from Visual Studio Installer, More, Repair(this takes some time).

    Best regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.