title: Determining Installed Visual Studio Path for 2017
body: <p>I have a powershell script that looks at a list of VS installations, and determines the highest version installed. It then uses the InstallDir for that version, and uses it to access various commands.</p>
  
  <p>It still <em>uses</em> the lower versions, however.</p>
  
  <p>As of VS2017, it appears that the Registry keys are <a href="https://developercommunity.visualstudio.com/content/problem/2911/vs2017-rc-installer-does-not-write-registry-entrie.html" rel="nofollow noreferrer">no longer saved in the same way</a>. I need to update the script to be able to figure out the 2017 settings.</p>
  
  <pre><code>#Add New Versions to this list when new versions of VS are released
  $VsVersionsToDisable = "10.0", "11.0", "12.0", "14.0"
  
  [System.Collections.ArrayList]$VsVersions = $VsVersionsToDisable
  
  #Find the Highest installed VS Version, and use it for the TFS.exe Command.
  foreach ($version in $VsVersions | Sort-Object -Descending)
  {
      $keyPath = "HKCU:\Software\Microsoft\VisualStudio\$version`_Config"
      If (Test-Path $keyPath)
      {
          $aliasPath = Get-ItemProperty -Path $keyPath | Select-Object `
                              -ExpandProperty InstallDir
          $proxyPath = Join-Path $aliasPath "tf.exe"
          set-alias proxyTF $proxyPath
      }
  }
  </code></pre>
  
  <hr>
  
  <p>To avoid an XY question: We use this script to configure the TFS Proxy settings for a user. It determines the highest installed version, uses it to find the proxy, then iterates through the lower versions configuring their proxy settings with the same value.</p>
  
  <hr>
  
  <p>What is the best way to determine the installation directory (and also the <code>tf.exe</code> location) for VS2017?</p>