Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly determine the 64-bit "Program Files" folder - fixes #1286 #1623

Merged
merged 1 commit into from
Aug 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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