Dir .: C:\Program Files (x86) and c:\Program Files
Dir .: C:\Program Files (x86) and c:\Program Files
Hello!
In this computer I have two program catalogs.
One catalog is "c:\Program Files" and the other "c:\Program Files(x86)".
I have no idea what is different between these programs directories.
If I use the AHK system variable A_ProgramFiles, it contains c:\Program Files
I want to create an shortcut to an installed windows program.
That's no problem to use A_ProgramFiles if the win program is installed in "c:\Program Files\..."
But, if the AHK Application is moved from computer "1" with the win prog installed on "c:\program_files\..." to computer "2". The Win program is installed in "c:\program_files(x86)\..."
________
Is the only way is to change my AHK-script to the right program path on every computer?
//Jan
In this computer I have two program catalogs.
One catalog is "c:\Program Files" and the other "c:\Program Files(x86)".
I have no idea what is different between these programs directories.
If I use the AHK system variable A_ProgramFiles, it contains c:\Program Files
I want to create an shortcut to an installed windows program.
That's no problem to use A_ProgramFiles if the win program is installed in "c:\Program Files\..."
But, if the AHK Application is moved from computer "1" with the win prog installed on "c:\program_files\..." to computer "2". The Win program is installed in "c:\program_files(x86)\..."
________
Is the only way is to change my AHK-script to the right program path on every computer?
//Jan
Re: Dir .: C:\Program Files (x86) and c:\Program Files
32 bit and 64 bit programs:Albireo wrote:Hello!
In this computer I have two program catalogs.
One catalog is "c:\Program Files" and the other "c:\Program Files(x86)".
I have no idea what is different between these programs directories.
"c:\Program Files" has 64 bit programs.
"c:\Program Files(x86)" has 32 bit programs.
Figured I would clarify this part.
Re: Dir .: C:\Program Files (x86) and c:\Program Files
A simple if statement checking if the OS is 64bit or not will work.
Code: Select all
;Always have dir point to 32bit Program Files
if A_Is64bitOS
dir := "C:\Program Files (x86)\Some Program"
else
dir := "C:\Program Files\Some Program"
Re: Dir .: C:\Program Files (x86) and c:\Program Files
Sometimes a user with 64bit Windows may have installed a 32bit version of some application though. So when writing ahk code that other people will use and that makes use of some installed program, check both locationsElesar wrote:A simple if statement checking if the OS is 64bit or not will work.
Code: Select all
if FileExist("C:\Program Files\golf\golf.exe")
dir := "C:\Program Files\golf\golf.exe"
else if FileExist("C:\Program Files (x86)\golf\golf.exe")
dir := "C:\Program Files (x86)\golf\golf.exe"
else
return ;or whatever you want to do if golf.exe is not found
Re: Dir .: C:\Program Files (x86) and c:\Program Files
Code: Select all
#NoEnv
MsgBox, 0, ProgramFiles32, % ProgramFiles32()
ProgramFiles32() {
If (A_Is64bitOS)
EnvGet, PF32, ProgramFiles(x86)
Else
PF32 := A_ProgramFiles
Return PF32
}
Re: Dir .: C:\Program Files (x86) and c:\Program Files
In some countries, the name of the directory isn't "Program Files" or "Program Files (x86)". It can use "Programme" or something like that. So it's best to use A_ProgramFiles or the environmental variables to get everything but the " (x86)" and then determine whether to add it or not once you determine which directory the file you want is in. Don't forget to include the space before "(x86)" or it won't find that directory.
Re: Dir .: C:\Program Files (x86) and c:\Program Files
Ok, so if we also cover that 64bit OS users may have 32bit version of a program installed we'd do:
Code: Select all
app := "\golf\golf.exe"
if FileExist(A_ProgramFiles app)
dir := A_ProgramFiles app
else if FileExist(A_ProgramFiles " (x86)" app)
dir := A_ProgramFiles " (x86)" app
else
return ;or whatever you want to do if golf.exe is not found
Re: Dir .: C:\Program Files (x86) and c:\Program Files
Thanks everyone!
The problem is not so easy to solve, but I think that the last solution can do it automaticly for me.
//Jan
The problem is not so easy to solve, but I think that the last solution can do it automaticly for me.
//Jan