User Submitted Macro

Program Files Folder

Written by Kevin Heaton, Insight Software Solutions

What it does

This sample macro, available for both Macro Express and Macro Express Pro, demonstrates how to get the Program Files folder that is used for 32 bit applications.

Many of my macros launch programs. For those with computers set to use the English language, programs have traditionally been installed in the ‘Program Files’ folder of the C: drive. With 64 bit Windows, however, 32 bit programs are, by default, installed under the ‘\Program files (x86)’ folder. Only 64 bit programs are installed under ‘c:\Program Files’.

I could simply edit my macros to replace ‘C:\Program Files’ with ‘C:\Program Files (x86)’ but my macros are used on several computers, some of which run the 32 bit version of Windows. Rather than have separate macros for each computer, I have changed my macros to get the correct Program Files folder from Windows itself.

To install

Download either the Macro Express 3 or Macro Express Pro version of the macro file and save it to your hard drive. Open the macro file import the macros into your existing macro file by clicking File, Import, Import Macros.

Program Files Folder – for Macro Express 3umprogramfilesfolder3.mex
Program Files Folder – for Macro Express 5 and Macro Express Proumprogramfilesfolder.mex

To use

There is no macro activation assigned to this macro. To run it, highlight it in the Macro Explorer window and click the run button. Use this example macro to modify your own macros to determine where 32 bit applications have been installed on your computer.

How it works

Windows sets environment variables that contain the path to the Program Files folder on your computer. For 64 bit versions of Windows, more than one environment variable is defined. This macro reads the environment variables to get the path to the folder where 32 bit applications are installed.

Limitations

As written, this macro returns the Program Files folder for 32 bit applications. You will need to modify this macro to get the Program Files folder for 64 bit applications.

Written for the English versions of Windows.