Welcome to MSDN Blogs Sign in | Join | Help

jaredpar's WebLog

Code, rants and ramblings of a programmer.

Syndication

News

Now Reading

Expert F#

What's a better book to read when learning F#?

Essential WPF

Thus far the best book I've read on WPF. Gets right down to working with WPF and the goals/history.

Purely Functional Data Structures

Reading this book makes me feel like I'm back in college. It will really get your mind going and is best read with a whiteboard handy.

Blog Roll

Eric Lippert
Dustin Campbell
Jon Skeet
Coding Horror
Brian McNamara
Brian Bondy
Hub FS
Full List

Program Files, I just want the 32 bit version

As part of my transition into using 64 bit windows I keep running into a problem with some scripts. 

I have a whole set of Powershell scripts that are dedicated to ensuring certain programs are installed on all of my dev machines.  Or that certain customizations are needed.  A lot of these do file existence checks inside of Program Files. 

Unfortunately in 64 bit windows there are actually two Program Files folders.  One for 64 bit programs and a separate one for 32 bit programs that operate in Wow64 mode.  All code which uses $env:ProgramFiles will point to the 64 bit version.  Most of the programs I custom install (i.e. gvim are actually 32 bit programs). 

Getting the 32 bit Program Files directory is simple enough: ${env:ProgramFiles(x86)}.  Yet it's not portable back to a 32 bit version of windows.  Yet another function to the rescue

function Get-ProgramFiles32() {
    if (Test-Win64 ) {
        return ${env:ProgramFiles(x86)}
    }
    
    return $env:ProgramFiles
}

Published Tuesday, October 21, 2008 8:00 AM by Jared Parsons

Filed under: ,

Comments

No Comments

New Comments to this post are disabled
Page view tracker