Determine Program Files Directory
Moderators: JRL, Dorian (MJT support)
Determine Program Files Directory
I have a program that I use to create installs for compiled MS Scripts and it works fine. In the past I have always used a fixed sub directory off of the C: drive. However I am now installing to a sub directory of "Program Files" and this is where the difficulty comes.
In different languages Program Files is called something different. For instance in Swedish it is called just "C:\Program". The installer knows where to place the files and does so correctly, but I don't know how to point to them to execute them.
Is there a way to determine the programs directory like there is the windows temp directory path (TEMP_DIR)?
In different languages Program Files is called something different. For instance in Swedish it is called just "C:\Program". The installer knows where to place the files and does so correctly, but I don't know how to point to them to execute them.
Is there a way to determine the programs directory like there is the windows temp directory path (TEMP_DIR)?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
GetEnvVar>ProgramFiles,Prog_Files
MessageModal>Prog_Files
MessageModal>Prog_Files
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
GetEnvVar>
Thanks,
As ususal when I find something new I look it up in the help file. So, I checked the help file for "GetEnvVar>" and it didn't say much. Is there a list of the items it can get?
As ususal when I find something new I look it up in the help file. So, I checked the help file for "GetEnvVar>" and it didn't say much. Is there a list of the items it can get?
Open a DOS prompt, type "set" and press enter. All the environment variables on that computer will be displayed.
You should also be aware that environment variables can be set by the user or by other programs. That's why they're called "variables". The point is there can be an issue if for example the "ProgramFiles" environment variable was reset to have a value of C:\windows. Its not likely to happen. But you should be aware that it could.
You should also be aware that environment variables can be set by the user or by other programs. That's why they're called "variables". The point is there can be an issue if for example the "ProgramFiles" environment variable was reset to have a value of C:\windows. Its not likely to happen. But you should be aware that it could.
Set
JRL
Thanks, I have decided that the best way to go on this is to write the path to the progam in the registry and then read it so that it will make no difference where it is installed.
Naturally, the down side is that the install needs to be run before the progam is written. Not really a big deal as when writing it, the registry lines can be written and then remarked out before compile time.
kp
Thanks, I have decided that the best way to go on this is to write the path to the progam in the registry and then read it so that it will make no difference where it is installed.
Naturally, the down side is that the install needs to be run before the progam is written. Not really a big deal as when writing it, the registry lines can be written and then remarked out before compile time.
kp
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Another way:
Code: Select all
Let>PATH_SIZE=260
Let>CSIDL_PROGRAM_FILES=38
LibFunc>shell32.dll,SHGetFolderPathA,r,0,CSIDL_PROGRAM_FILES,0,0,PATH
Pos>NULLCHAR,r_5,1,p
MidStr>r_5,1,{%p%-1},ProgFiles
MessageModal>ProgFiles
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi Marcus,
Thanks for the above method of directly determining the Programs directory (without having to write to the registry) but can you also tell us why you used the following line?
You don't reference that variable again in your script... so no other command is making use of it... so why are you setting it to 260?
I searched the forums and the only other mention of PATH_SIZE is in some similar code you posted here: list of file/path references?
Thanks
Thanks for the above method of directly determining the Programs directory (without having to write to the registry) but can you also tell us why you used the following line?
- Let>PATH_SIZE=260
You don't reference that variable again in your script... so no other command is making use of it... so why are you setting it to 260?
I searched the forums and the only other mention of PATH_SIZE is in some similar code you posted here: list of file/path references?
Thanks
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Please see the LibFunc help topic.
I use PATH as the buffer variable in the LibFunc call. Adding _SIZE to the variable placed in the LibFunc call is done to specify the size of the buffer.
The docs for SHGetFolderPathA say the buffer should be MAX_PATH which is 260.
I use PATH as the buffer variable in the LibFunc call. Adding _SIZE to the variable placed in the LibFunc call is done to specify the size of the buffer.
The docs for SHGetFolderPathA say the buffer should be MAX_PATH which is 260.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Hi Marcus,
Very good, I see it now, thanks for the clarification.
All I could find about "MAX_PATH" from Microsoft was here: http://msdn.microsoft.com/en-us/library/aa365247.aspx
It says it is 260 chars.
What link were you using as documentation on the SHGetFolderPathA win32 api call?
I'm finding pages marked "depricated" as Vista must use a different call to achieve the same thing.
Very good, I see it now, thanks for the clarification.
All I could find about "MAX_PATH" from Microsoft was here: http://msdn.microsoft.com/en-us/library/aa365247.aspx
It says it is 260 chars.
What link were you using as documentation on the SHGetFolderPathA win32 api call?
I'm finding pages marked "depricated" as Vista must use a different call to achieve the same thing.
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
