Skip to content

Commit

Permalink
Correctly determine the 64-bit "Program Files" folder - fixes #1286
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaDrivenDev committed Jul 29, 2017
1 parent 291f58c commit b8fb237
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/app/FakeLib/EnvironmentHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,25 @@ let inline getBuildParamOrDefault name defaultParam =
let inline getBuildParam name = getBuildParamOrDefault name String.Empty

/// The path of the "Program Files" folder - might be x64 on x64 machine
let ProgramFiles = Environment.GetFolderPath Environment.SpecialFolder.ProgramFiles

/// The path of Program Files (x86)
/// It seems this covers all cases where PROCESSOR\_ARCHITECTURE may misreport and the case where the other variable
/// PROCESSOR\_ARCHITEW6432 can be null
let ProgramFilesX86 =
let ProgramFiles =
let wow64 = environVar "PROCESSOR_ARCHITEW6432"
let globalArch = environVar "PROCESSOR_ARCHITECTURE"
match wow64, globalArch with
| "AMD64", "AMD64"
| null, "AMD64"
| "x86", "AMD64" -> environVar "ProgramFiles(x86)"
| "x86", "AMD64"
| "AMD64", "x86" ->
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion")
.GetValue("ProgramFilesDir")
.ToString()
| _ -> environVar "ProgramFiles"
|> fun detected -> if detected = null then @"C:\Program Files (x86)\" else detected
|> fun detected -> if detected = null then @"C:\Program Files\" else detected

/// The path of Program Files (x86)
let ProgramFilesX86 = Environment.GetFolderPath Environment.SpecialFolder.ProgramFilesX86

/// The system root environment variable. Typically "C:\Windows"
let SystemRoot = environVar "SystemRoot"
Expand Down

0 comments on commit b8fb237

Please sign in to comment.