locked
WindowsSdkDir is wrong, how to change?

    Question

  •  

    $(WindowsSdkDir) environment variable in Visual C++ 2008 Express Edition is pointing to:

     

     C:\Program Files\Microsoft Visual Studio 9.0\VC\PlatformSDK

     

    instead of:

     

    C:\Program Files\Microsoft SDKs\Windows\v6.0A

     

    I have a similar problem in vc++ 2005. In general, how do I change an environment variable? I have searched the online help, the msdn forums, and the internet at large and I still can't find how to modify a visual studio environment variable. I have tried editing vcvars.bat, searching the registry, and resetting all settings, but I still can't figure out how to do this.

    Tuesday, November 20, 2007 5:01 AM

Answers

  • I had the exactly same problem on the PC in my home, that's why I googled and find this topic.

     

    Finding no answer on the web, I read the batch file "vsvars32.bat" under "Microsoft Visual Studio 9.0\Common7\Tools", which sugguests the var comes from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder" in the registry.

     

    The value was there on my working machine, but not on my home desktop, and my working machine works fine. Why was that? later I deleted the previously installed "platform sdk"---which I thought no longer necessary for vc 2008 e---from my working machine and the value vanished.

     

    I guess this was how it turned bad: we installed vc2008express after "psdk", then found "psdk" redundant and got rid of it, and the uninstallation process removed the registry value its installation process added.

     

    The fix is easy: either to reinstall 2008 or to add a value in the registry (with the content equal to the vc2008 sdk path).

    Wednesday, November 21, 2007 6:55 AM

All replies

  • I had the exactly same problem on the PC in my home, that's why I googled and find this topic.

     

    Finding no answer on the web, I read the batch file "vsvars32.bat" under "Microsoft Visual Studio 9.0\Common7\Tools", which sugguests the var comes from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder" in the registry.

     

    The value was there on my working machine, but not on my home desktop, and my working machine works fine. Why was that? later I deleted the previously installed "platform sdk"---which I thought no longer necessary for vc 2008 e---from my working machine and the value vanished.

     

    I guess this was how it turned bad: we installed vc2008express after "psdk", then found "psdk" redundant and got rid of it, and the uninstallation process removed the registry value its installation process added.

     

    The fix is easy: either to reinstall 2008 or to add a value in the registry (with the content equal to the vc2008 sdk path).

    Wednesday, November 21, 2007 6:55 AM
  • I installed Visual C++ 2008 Express and then Vista Platform SDK with the idea of getting help on win32 SDK via F1.  I had to change:

     

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\MicrosoftSDKs\Windows\CurrentInstallFolder

     

      c:\program files\microsoft sdks\windows\v6.0\ -> c:\program files\microsoft sdks\windows\v6.0A\

    Saturday, December 1, 2007 5:36 AM
  • My path was broken after installing Vista SDK tools after VS2008.  In addition to the change Adam mentions above, I also needed to update:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDKs\Windows\CurrentVersion and CurrentInstallFolder

    ...to add the 'A'.

    • Proposed as answer by Pavel S Friday, April 23, 2010 12:31 PM
    Monday, February 9, 2009 2:05 PM
  • Recent versions of the SDK come with WindowsSdkVer.exe, which can be used to select a specific version of the SDK and make it the default in Visual Studio.

    For example look it in C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup

    Microsoft Xbox Test - http://tester.poleyland.com/
    • Proposed as answer by Josh Poley Thursday, September 9, 2010 3:54 PM
    • Unproposed as answer by Josh Poley Tuesday, May 10, 2011 8:12 PM
    Thursday, March 18, 2010 4:41 PM
  • A simple solution (for specific projects) that I found for this SDK problem in Visual Studio 2010 was:

    project properties -> Configuration properties -> VC++ Directories -> Include Directories -> Insert a different SDK include library

    It take precedence over the VS inherited v7.0 libraries.

    Tuesday, June 1, 2010 12:33 PM
  • this _DOESN'T_ work for VS2010.  While the WindowsSdkVer tool reports that it has successfully changed SDK's, the $(WindowsSdkDir) macro in VS2010 remains V7.0a!
    • Proposed as answer by Dan VB Friday, September 17, 2010 9:07 PM
    Sunday, July 18, 2010 10:43 PM
  • Hello,

    If you have a version of Visual Studio 2010 installed (including Express version that I use) with Windows 7.1 SDK, you can actually set in the Solution Explorer of one of your opened solution which platform toolset you want to use. Once you've selected "Windows SDK 7.1", the macro $(WindowsSdkDir) will be updated.

    For more information, read the "Samples Reference" of Windows SDK (you should see the shortcut in Programs> Microsoft Windows SDK 7.1) which contains a paragraph about : How To: Using the Platform Toolset With Visual Studio 2010 :

    " Visual Studio 2010 users can make use of the new Native Multitargeting functionality of the Platform Toolset to target the Windows SDK v7.1 components. 

    1.     Start Visual Studio 2010

    2.     In the Visual Studio IDE, open a solution file (*.sln)

    3.     In Solution Explorer, right click the solution file and select Properties

    4.    Select Configuration Properties, General from the list in the left pane

    5.     Select All Configurations in the Configuration dropdown

    6.     Select Windows7.1SDK in the Platform Toolset option in the right pane under the General category.

    7.     Click the Ok button "

    The Windows SDK Configuration Tool shipped with the SDK is apparently designed to work for Visual Studio 2005 or 2008, not 2010.

    Tuesday, September 14, 2010 8:40 AM
  • This is really frustrating.

    For Visual Studio 2010 it is really regrettable that the WindowsSDKDir environment variable is clobbered by the vcvars32.bat file (during a call to VCVarsQueryRegistry.bat), and always replaced explicitly with the v7.0A version of the SDK. You can actually work around that by editing VCVarsQueryRegistry not to clobber the environment variable if it is defined, or to use this code instead of the similar code that's under the :GetWindowsSdkDirHelper label...

    @for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder"') DO (
        @if "%%i"=="CurrentInstallFolder" (
            @SET "WindowsSdkDir=%%k"
        )
    )

    ...to use the current Platform SDK that is actually configured in the registry.

    I've done this to try to build a set of a couple dozen related projects under v7.1 of the Platform SDK. Very unfortunately, even when launched from a command window that has run VCVARS32.BAT modified in this way, the Visual Studio 2010 development environment will not use the WindowsSDKDir environment variable, because of the Platform Toolset setting present in every project file, which overrides the environment. The v100 setting for the toolset will not use the 7.1 SDK. You have to edit every project to use the v7.1 version of the toolset setting.

    This seems like a very strange way to implement Platform SDK support in Visual Studio 2010.

     

    Tuesday, May 10, 2011 5:31 PM
  • Recent versions of the SDK come with WindowsSdkVer.exe, which can be used to select a specific version of the SDK and make it the default in Visual Studio.
    For example look it in C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup

    Microsoft Xbox Test - http://tester.poleyland.com/


    I have recently stubled upon a similar problem to the OA's. I'm using VS2008 and its WindowsSDKDir permanetnly points to the c\programfiles\...\v6.0a version, and that small thing prevents me from compiling some of the SDK shell samples properly.

    After reading the post about the registry key and WindowsSdkVer.exe I though "whoa, that's it!", so I run it, selected 7.1, and the tool informed me that "You don't have VS2005 nor VS2008 installed". Yeah, right, sure waitasec I forgot to install it, eh :| Without sarcasm, I guess that the problem may lie in the fact I also have VS2010Express installed (it came with WindowsPhone SDK/Tools/etc) and maybe that simple tool detects that I already have "too new" VS version that deals with the platform-choosing-problem in a different way (see insightful post of ThunderLight4MSDN).

    So, I've tried changing the registry key manually. I've edited both the

        HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDKs\Windows\CurrentVersion

    and

        HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MicrosoftSDKs\Windows\CurrentInstallFolder

    to point to the "v7.1", and .. nothin. The VS2008 still uses v6.0A.

    Then, I have had a thought: the HKEY_LOCAL_MACHINE usually keeps the DEFAULTS which are later masked with sister keys in HKEY_CURRENT_USER, to provide per-user configurations. So, I jumped to

        HKEY_CURRENT_USER\Software\Microsoft\Microsoft SDKs\Windows

    only to find that there, too, exist values 'CurrentVersion' and 'CurrentInstallFolder', and they were set, of course, to v6.0a.

    After changing them to v7.1 (and restarting VS2008), $(WindowsSDKDir) switched to that of 7.1, constants like _WIN32_WINNT_LONGHORN have instantly appeared in the namespace, and all the samples have built correctly.

    I believe that the only thing you have to change, are the two values under HKEY_CURRENT_USER. Just as a precaution, I have left those in LOCAL_SYSTEM updated too, but I really think that was unnecessary. Probably deleting the key in HKCU would work too.

    Hope this helps someone.

    Tuesday, June 21, 2011 6:26 PM
  • Had this same problem after uninstalling a Vista SDK.  FIX: Added string CurrentInstallFolder and set to C:\Program Files\Microsoft SDKs\Windows\v6.0A\ in the reg folder HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows

     

    Thursday, August 18, 2011 9:13 PM
  • 1) Where is Configuration Properties -> General in the left?
    2) Where is the Platform Toolset option?
    3) If I'm on the correct screen, and Platform is what is meant by 'Platform Toolset', where is Windows7.1SDK?
    $(WindowsSdkDir) points to Windows 7.0a. I have never installed that version, only 7.1 I have no clue why it points to something that was never installed, and would like it to work properly.
    EDIT: Oh, even better, now I see there does exist a 7.0a installation. Which is missing several key files. And I still can't make it point to 7.1. I also can't use thogwiloc's solution of editing the .bat file because access is denied. Maybe I'll just go develop with openGL instead.

    • Edited by CrushU Saturday, November 5, 2011 6:53 PM
    Saturday, November 5, 2011 6:43 PM
  • Hey CrushU,

    Had the same problem, tried the regestry tips above ( to no avail, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs did not exist, let alone the subfolder and keys..?.?.. )

     

    but i found where the General, Platform Toolset, and Windows 7.1 can be set.

    I have MS Visual Studio C++ 2010 Express ( Specificly: version 4.0.30319 )

    On the left menu make sure a Project is highlighted. ( not a Solution, or this will not generate the 'General' subsection needed later )

    THEN :

    Go to file menu : Project : Properties   ( or hit F7 )

    Under 'Config Properties'/'General'

    Select Configuration: 'All Configurations' ( This is not nessisary to see the 'Platform Toolset' option, but will allow you to set the variable for both debug and release {i suppose you could define them seperately or install multiple SDK's and assign them to different debug and release configurations.?.?. anyone confirm this?} )

    Ok, then under the 'General' section on the RHS, the bottom item : 'Platform Toolset' ( ! Hurray ! )

    and hope to god that 'Windows7.1SDK' is an option ( or something must have gone terribly wrong during installing the SDK )

    And an image for those Graphically inclined...

    And now after a several hours of pain and suffering and frustration, I am going to eat something, then compile the CUDA SDK Examples in 64bit ( Shameless SEO ).

    I hope this help you out.

    Ka Azure.

    • Proposed as answer by Crossfire_ Saturday, June 23, 2012 9:06 PM
    Wednesday, January 11, 2012 12:48 PM