Michael - I hadn't seen that (why?) - and my supposition about 3.5 vs 4.0
Framework was right. 

Since I need to use v3.5, I'll work with ExpandEnvironmentVariables. 

Thanks! 

  _____  

Ian Thomas
Victoria Park, Western Australia

  _____  

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Michael Minutillo
Sent: Wednesday, February 08, 2012 4:46 PM
To: ozDotNet
Subject: Re: Environment variable ProgramFilesx86 - for x86 on 64-bit
Windows

 

Hi Ian,

If all you want to do is start a process in code you can use the
Environment.ExpandEnvironmentVariables(..) method to do it for you:

Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%\\TextPad
5\\TextPad.exe")

Returns

C:\Program Files (x86)\TextPad 5\TextPad.exe 

on my machine. If you reference an environment variable that doesn't exist
then it just doesn't get expanded.

Regards,

Michael M. Minutillo
Indiscriminate Information Sponge
http://codermike.com



On Wed, Feb 8, 2012 at 4:36 PM, Ian Thomas <il.tho...@iinet.net.au> wrote:

Is there an environment variable ProgramFilesx86 to locate C:\Program Files
(x86) on a 64-bit Windows? 

Although some of the MSDN documentation specifically mentions an environment
variable ProgramFilesX96 member in the Environment.SpecialFolder Enumeration
(http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.as
px ), it isn't shown by intellisense -
Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesx86)
and doesn't compile. 

Further, while I can use the Windows Run to expand %ProgramFiles(x86)% - 

"%ProgramFiles(x86)%\TextPad 5\TextPad.exe" -m -r  "C:\Users\(some
location)\MyApp.log"

will work as desired, for example - if I want to start a process in code it
doesn't expand the environment variable - 

MyProcess.StartInfo.Filename = "%ProgramFiles(x86)%\TextPad 5\TextPad.exe"

(fails) 

I am using 3.5 Framework, and need to remain with this. Maybe in 4.0 the
doco is correct and this works (have not tried) - or am I missing a few very
obvious things? 

  _____  

Ian Thomas
Victoria Park, Western Australia

 

Reply via email to