It is depending on the program you install.
Some programs let you chose where you want to install them some others not.
As for your example firefox, after downloading run it as administrator,
it will start extracting.
After the extract the first page of the installer will pop up where it says
that you will istall firefox, just press next since most of the times there are
no options at the first page of the installers.
On the second page you will notice that you have to make a decision
between Typical installation or custom installation.
In your case check custom and press next.
Now you should notice that on the 3rd page of the installer there should be
an instalation directory for example C:\Program Files\Mozilla Firefox\
you can change it if you press browse and than navigate to your second hard disk.
After this just finish your installation just as usual.