4

My boss needs an installer to setup software onto one of our client's machines. He wants the software to be installed specifically into "C:\Program Files\HisApplicationName", not "C:\Program Files (x86)\HisApplicationName". I know the correct answer would be to rewrite the software to accomodate any directory the user chooses to install to, but unfortunately, this is very old sofware & needs to be installed tomorrow, so we just want to force the installer to point to the client's "Program Files" directory.

My problem though, is when I hardcode the filepath into the installer's "DefaultLocation" property, the installer still tries to point to the Program Files (x86) directory instead.

Is there any way to force the windows setup/installer package to point to Program Files & not "Program Files (x86)"?

Thanks.

goalie35
  • 786
  • 3
  • 14
  • 34
  • 2
    It goes into "Program Files (x86)" because it's a 32-bit application. That's where it belongs unless the owner of the machine itself changes the policy. Trying to work against this is like those 90's home pages that had instructions on how to change your browser's main window size and default fonts and colors to suit the site. – Marcelo Cantos Mar 15 '12 at 01:53
  • Thanks for the reply Marcelo. Unfortunately, this isn't an option. To be honest, it's a terrible piece of software, that specifically looks for files in the "Program Files" directory. Looking in any other directory will throw an error. If I had time to rewrite this, I would, but unfortunately, this client needs this by tomorrow. – goalie35 Mar 15 '12 at 03:25
  • If it's a one-off for a specific client, perhaps creating a link (assuming Vista/Win7) will resolve the issue. – Marcelo Cantos Mar 15 '12 at 06:09

1 Answers1

17

What you are asking to do simply isn't possible with Windows Installer with the exception of one unsupported subversive hack.

Set the INSTALLDIR to C:\Progra~1\.....

See, MSI has functionality for backwards compatibility that automatically "fixes" any hard coded references of C:\Program Files\ to C:\Program Files (X86) when the MSI is marked as 32 bit. It fails to calculate the shortname version and redirect it so my hack works. Assuming they haven't disabled short filename system.

The only proper way to install to C:\Program Files is to mark the MSI as 64-bit and use the ProgramFiles64Folder property instead of the ProgramFilesFolder property.

BTW, if your boss won't believe you, then I suggest finding a new boss. I've been writing installers for 16 years and I never let some PHB make decisions like this. I'm the Windows Installer expert, not him.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • Thanks. This worked! I understand this is a hack and I would never take this approach with a typical install, but for the purpose of installing this old, clunky software...it did the trick! – goalie35 Mar 16 '12 at 01:48
  • Great answer! (Especially the last bit!!) – tommed Aug 13 '12 at 16:24
  • Works like a charm, how did i not find this sooner! Thanks – user616 Nov 16 '15 at 16:57
  • 1
    Upvote for flaming the PHB, Lol. Also, this seems useful. – J Weezy Apr 21 '21 at 15:38
  • I've now been writing installers for 25 years! :) Thankfully the PHB hasn't been an issue for a long time. I've actually been working at one place (The Home Depot) for 10 years now. Great company to work for. – Christopher Painter Apr 21 '21 at 15:52