Failed to generate project files, System.ArgumentOutOfRangeException

I get this error when I tried to create any c++ project:

Failed to generate project files. Log
output: Running C:/Program Files/Epic
Games/4.7/Engine/Binaries/DotNET/UnrealBuildTool.exe
-projectfiles -project=“C:/Users/Van/Documents/Unreal
Projects/Fly/Fly.uproject” -game
-rocket -progress Discovering modules, targets and source code for game…
UnrealBuildTool Exception:
System.ArgumentOutOfRangeException:
Length cannot be less than zero.
Parameter name: length at
System.String.Substring(Int32
startIndex, Int32 length) at
UnrealBuildTool.Utils.SetEnvironmentVariablesFromBatchFile(String
BatchFileName) at
UnrealBuildTool.VCEnvironment…ctor(CPPTargetPlatform
InPlatform) at
UnrealBuildTool.VCToolChain.GetVCIncludePaths(CPPTargetPlatform
Platform) at
UnrealBuildTool.VCProjectFile.WriteProjectFile(List1 InPlatforms, List1 InConfigurations)
at
UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles()
at
UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(String
Arguments, Boolean& bSuccess) at
UnrealBuildTool.UnrealBuildTool.GenerateProjectFiles(ProjectFileGenerator
Generator, String Arguments) at
UnrealBuildTool.UnrealBuildTool.Main(String
Arguments)

Been trying to find a solution for months now. Still nothing.
Win 7 64bit, VS 2013 Ultimate

If the arguments are: -projectfiles -project=“C:/Users/Van/Documents/Unreal Projects/Fly/Fly.uproject” -game -rocket -progress,
How can that length be less than zero?

Hey -

Just to make sure I understand what’s happening on your end I want to clarify that you receive this error when you create a code based project, correct? Are you using a source build of the engine from GitHub or are you using the Launcher? If you are using the Launcher you can click the drop down arrow for your engine version and select Verify. If you are still having problems let us know along with any additional information about how you’re setting up the project and exactly when this error occurs.

Cheers

Yes, this happens when I create a C++ based project, Blueprint projects seem to work just fine.
I am using the Launcher version of unreal engine. I have the latest version, 4.7.1. I ran verify, but I’m still getting the same error.
As soon as I click ‘Create Project’, with Desktop/Console, Maximum Quality, and With Starter Content selected; The creating project progress bar gets to 90%, then I get the error message I posted above.

This is very confusing. I have the exact same version of VS on my Windows8 laptop and the unreal engine doesn’t have this issue. I’m not sure whats causing it.

Does the same crash occur if you use another version of the engine from the Launcher? If so then there may be an issue with the version of Visual Studio on your computer and may need to re install it. If another engine version does not crash then it may help to uninstall 4.7.1 and then re-download it. Let me know if either of these options help.

Yes, it crashes on all versions. I have tried uninstalling/reinstalling both VS and Unreal Engine, but get the same results.

Hey -

As mentioned here ([4.7] UnrealBuildTool Failed to generate project files - C++ - Epic Developer Community Forums) it seems that your %TEMP% folder may have too many files in it and needs to be cleaned up / cleared out. This should free up the space needed to make new projects.

Cheers

I cleared my temp folder, but the result is the same.

I came across another users post that seems to be having a similar issue to what you’re describing. Could you try the solution in the post below and let me know if that helps?

Thanks so much . This solution didnt really solve the cause of the problem, but repeating the steps for his solution helped me at least find the cause. Turns out I was causing the issue myself, I just didnt how.
My buddies and I run our unreal engine launcher through the Steam client, which is cool because broadcast and everything works. I guess at some point, perhaps a steam update caused this to not work any more and causes the error that I showed above. Not sure why though.

Thanks again

PS: if you get bored and feel like looking into the steam client thing, that would be great, but its no big deal.