Windows.h error in new C++ project

I’ve spent more than 15 hours over the course of two days trying to fix this error. Whenever I create a new project the build fails and gives the following errors, all related to windows.h:

Error RC1015 cannot open include file 'windows.h'.	Test	C:\Program Files (x86)\Epic Games\4.13\Engine\Source\Runtime\Launch\Resources\Windows\PCLaunch.rc
Error RC1015	cannot open include file 'windows.h'.	Test	C:\Program Files (x86)\Epic Games\4.13\Engine\Source\Runtime\Core\Resources\Windows\ModuleVersionResource.rc.inl	
Error Failed to produce item: D:\Documente\Projects\Unreal\Projects\TestProject\Test\Binaries\Win64\UE4Editor-Test.dll	Test	D:\Documente\Projects\Unreal\Projects\TestProject\Test\Intermediate\ProjectFiles\ERROR	
Error C1083 Cannot open include file: 'windows.h': No such file or directory	Test	c:\program files (x86)\epic games\4.13\engine\source\runtime\core\public\Windows\MinWindows.h
Error MSB3075	 The command ""C:\Program Files (x86)\Epic Games\4.13\Engine\Build\BatchFiles\Build.bat" TestEditor Win64 Development "D:\Documente\Projects\Unreal\Projects\TestProject\Test\Test.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.	Test	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets

Again, this happens in a completely fresh UE4 project. I’ve never used UE4 before and I want to get started, but this has stumped me completely. I have read every thread about this I could find and I still don’t know how to fix it. Here’s additional information:

  • I’m using Windows 7 and VS2015. I’ve
    already reinstalled UE4 once and
    updated and repaired VS2015 to make
    sure.

  • I have installed and repaired several
    Windows SDKs. I have 6.0, 6.1, 7.0,
    7.1, 8.0, 8.1 and 10. I don’t know which SDK UE4 needs specifically or if
    reinstalling any of them will help at
    this point. I’ve already reinstalled, repaired them a few times. I did not try uninstalling ALL of them at once yet.

  • I’ve tried fiddling in all sorts of
    ways with VC++ Directories in the UE4
    project. I tried inheriting from
    parent
    as other threads suggested. I
    tried pointing to SDK 7.1 where
    window.h is contained - I pointed to
    the include, lib and bin files in
    their appropriate fields. I’ve also tried pointing to the 7.1 include folder in the NMAKE Include Search Path.

  • I have created a new VS2015 console
    application project and did nothing
    but include windows.h. It worked
    immediately when targeting Windows
    SDK 10. I had to specify VC++
    Directories for Windows SDK 8 to
    work, but it did work.

  • My path variable and VS environment variables:
    http:///atmWD1wH

    VS110COMNTOOLS: D:\Programe\Microsoft Visual Studio 11.0 (VS2012 Ultimate)\Common7\Tools\
    VS120COMNTOOLS: D:\Programe\Microsoft Visual Studio 12.0\Common7\Tools\
    VS140COMNTOOLS: D:\Programe\Microsoft Visual Studio 14.0\Common7\Tools\
    
  • I’ve tried putting 7.1 include, bin
    and lib folders in and out of my path
    variable to see if it helps or not,
    but it didn’t.

  • I’ve tried running
    get_vs_environment.bat, which was mentioned in another thread, and there seem
    to be a lot of things missing there,
    but in that thread, the bat was used
    for for VS2013, I think,
    not VS2015. I’ve edited it to check
    VS140COMNTOOLS instead of
    VS120COMNTOOLS and the VS140 one looks fine. I’ve included both the VS120 and the VS140 edit here: http:///1HHRAh1R | http:///2NrdavK2

I’m at rope’s end, any help would be greatly appreciated.

Hello Voukras,

Thank you for all of the information, that lets us bypass a lot of questioning. The first thing I noticed is that your environment variables are pointing towards your Visual Studio installation being on your D:\ drive while it seems that your Windows installation is on your C:\ drive. This has caused problems in the past and is likely the cause for this issue. Visual Studio uses multiple things from the System32 folder so having it on a separate drive from your Windows installation can be problematic.

Would it be possible for you to try moving the installation over to your C:\ drive to see if that will work correctly?

Yes!!! It worked. Boy, that was a ■■■■■■■ adventure. And not the good kind.

Thank you so much for the response and your suggestion Matthew. It’s hard to tell if moving VS2015 to C:\ is what fixed it or the fact that I did the most rigorous uninstalling ever known to man. I broke my VS2015 twice in the process of figuring out how to properly uninstall it, so if anyone commits to doing this, be prepared for possible trouble.

After you install VS2015 in one place, it is not enough to simply uninstall it. It won’t let you choose a different path the next time you install it. You need to do much more to be able to move it. Uninstalling it inadequately and installing it in a different place lead to multiple components breaking and giving errors when VS2015 was opened. Whether or not moving it helped, doing all of this probably solved whatever dependency hell was going on. This is an approximate retelling of what I did that worked, properly uninstalling VS2015 can be pretty convoluted.

Here’s what you need:

  • VisualStudioUninstaller - Just
    grab the latest . of the release
    version.
  • PowerShell - Again, grab one of the latest release versions. This did not work
    off the bat for me, PowerShell would
    not recognize my commands. To make it work I also
    needed to install Windows Management
    Framework 5.0
    and then I opened
    PowerShell and ran install-package
    MSI –provider powershellget
    and said [A] Yes To All to the prompt to let it install everything it needed.

Steps:

  1. Navigate with cmd to your VS2015
    installer. Download it from
    Microsoft’s site if you need it. Use
    cmd to force the installer to
    uninstall everything it can,
    including components. For me, the
    command looked like this:
    vs_community_ENU /uninstall /force
  2. Run PowerShell as administrator and run get-msicomponentinfo ‘{777CBCAC-12AB-4A57-A753-4A7D23B484D3}’ | get-msiproductinfo (Source: How to install Visual Studio to another directory when a pre-release is installed)
  3. Run VisualStudioUninstaller and wait for it to scorch everything.
  4. Navigate to C:\Users\AppData\Local\Microsoft and rename or delete the VSCommon and VisualStudio directories if they still exist.
  5. Navigate to C:\Users\AppData\Roaming\Microsoft and rename or delete the VisualStudio directory.
  6. Restart and Install Visual Studio 2015.

I’m not sure which steps exactly need a restart but I am pretty sure that restarting after uninstalling is mandatory. I also did a bunch of Windows updates that may or may not have fixed something related to this bug.

After installing, VS2015 might fail to install certain components. If you try running VS2015 without them and it doesn’t work then it’s worth a shot to just run the installer again after restarting. If that doesn’t work try renaming C:\ProgramData\Package Cache\ Don’t outright delete it without backing it up because in some rare situations it might cause problems. After deleting it, try running in the installer again. The installer apparently has problems with partially downloaded things and gets stuck or something? I don’t know.

I was was having this same issue and your quick guide solved it! Thanks for posting!

Thanks, I had the same issue, you saved me like 10 more hours of exploring