Subject: Re: Program files environmental variables
From: Brian Inglis <[email-masked]>
To: [email-masked]
Date: Tue, 23 Nov 2021 11:07:17 -0700
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

On 2021-11-23 02:02, john doe via Cygwin wrote:
> Cygwins,
> 
> Is there a way to get the value of PROGRAMFILES(x86) and PROGRAMW6432 in
> Bash:
> 
> $ echo $PROGRAMFILES; echo "$PROGRAMFILES(x86)"; echo $PROGGRAMW6432
> C:\Program Files
> C:\Program Files(x86)
> 
> $ cmd.exe /C "echo %PROGRAMFILES% %PROGRAMFILES(x86)% %PROGRAMW6432%"
> C:\Program Files C:\Program Files (x86) C:\Program Files
> 
> 
> PROGRAMFILES works in Bash but not the other two.
> 
> I could not find anything relevent in the archive or when googling.

On my system under only the following Program... variables are exposed:

$ echo $ProgramData $PROGRAMFILES $ProgramW6432	# x64
C:\ProgramData C:\Program Files C:\Program Files
$ echo $ProgramData $PROGRAMFILES $ProgramW6432	# x86
C:\ProgramData C:\Program Files (x86) C:\Program Files

It is often a better idea to use cygpath options or Windows folder ids:

"System information:
-A, --allusers        use `All Users' instead of current user for -D, -P
-D, --desktop         `Desktop' directory
-H, --homeroot        `Profiles' directory (home root)
-O, --mydocs          `My Documents' directory
-P, --smprograms      Start Menu `Programs' directory
-S, --sysdir          system directory
-W, --windir          `Windows' directory
-F, --folder ID       special folder with numeric ID"

$ for f in {0..64}; do
     p=`cygpath -UF $f 2> /dev/null` && [ -n "$p" ] && echo $f $p
   done # sanitized
  0 $HOME/Desktop
  2 $HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs
  5 $HOME/Documents
  6 $HOME/Favorites
  7 $HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup
  8 $HOME/AppData/Roaming/Microsoft/Windows/Recent
  9 $HOME/AppData/Roaming/Microsoft/Windows/SendTo
11 $HOME/AppData/Roaming/Microsoft/Windows/Start Menu
13 $HOME/Music
14 $HOME/Videos
16 $HOME/Desktop
19 $HOME/AppData/Roaming/Microsoft/Windows/Network Shortcuts
20 /proc/cygdrive/c/Windows/Fonts
21 $HOME/AppData/Roaming/Microsoft/Windows/Templates
22 /proc/cygdrive/c/ProgramData/Microsoft/Windows/Start Menu
23 /proc/cygdrive/c/ProgramData/Microsoft/Windows/Start Menu/Programs
24 /proc/cygdrive/c/ProgramData/Microsoft/Windows/Start 
Menu/Programs/StartUp
25 /home/Public/Desktop
26 $HOME/AppData/Roaming
27 $HOME/AppData/Roaming/Microsoft/Windows/Printer Shortcuts
28 $HOME/AppData/Local
29 $HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup
30 /proc/cygdrive/c/ProgramData/Microsoft/Windows/Start 
Menu/Programs/StartUp
31 $HOME/Favorites
32 $HOME/AppData/Local/Microsoft/Windows/INetCache
33 $HOME/AppData/Local/Microsoft/Windows/INetCookies
34 $HOME/AppData/Local/Microsoft/Windows/History
35 /proc/cygdrive/c/ProgramData
36 /proc/cygdrive/c/Windows
37 /proc/cygdrive/c/Windows/System32
38 /proc/cygdrive/c/Program Files
39 $HOME/Pictures
40 $HOME
41 /proc/cygdrive/c/Windows/SysWOW64
42 /proc/cygdrive/c/Program Files (x86)
43 /proc/cygdrive/c/Program Files/Common Files
44 /proc/cygdrive/c/Program Files (x86)/Common Files
45 /proc/cygdrive/c/ProgramData/Microsoft/Windows/Templates
46 /home/Public/Documents
47 /proc/cygdrive/c/ProgramData/Microsoft/Windows/Start 
Menu/Programs/Administrative Tools
48 $HOME/AppData/Roaming/Microsoft/Windows/Start 
Menu/Programs/Administrative Tools
53 /home/Public/Music
54 /home/Public/Pictures
55 /home/Public/Videos
56 /proc/cygdrive/c/Windows/Resources
59 $HOME/AppData/Local/Microsoft/Windows/Burn/Burn

These output nothing:

$ printenv 'Program Files (x86)'
$ printenv 'ProgramFiles(x86)'

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple