I had the same problem and I created a PowerShell script that sets an environment variable with the path to the SDK bin folder. It will automatically search the registry and find the latest installed version. It also has a reserve of alternative registry location, depending on whether your script is running in 32-bit or 64-bit mode. Hope this helps!
Disclaimer: I removed some things from the script before posting it here, and I did not test it later, but I think it is not difficult to debug / configure it according to your needs.
Cyberdude
source share