Index: Win32/build/win32-packager.pl
===================================================================
--- Win32/build/win32-packager.pl	(revision 21900)
+++ Win32/build/win32-packager.pl	(working copy)
@@ -183,7 +183,6 @@
 my $mythtv  = 'C:/mythtv/';       # this is where the entire SVN checkout lives
                                   # so c:/mythtv/mythtv/ is the main codebase.
 my $build   = 'C:/mythtv/build/'; # where 'make install' installs into
-my $mysql   = 'C:/Program Files/MySQL/MySQL Server 5.1/';
 
 # Where is the users home?
 # Script later creates $home\.mythtv\mysql.txt
@@ -198,7 +197,18 @@
 $home =~ s/ /\\ /g;
 $home .= '/'; # all paths should end in a slash
 
+# Where are program files (32-bit)?
+my $dosprogramfiles = '';
+if ( $ENV{'ProgramFiles(x86)'} ) {
+  $dosprogramfiles = $ENV{'ProgramFiles(x86)'};
+} else {
+  $dosprogramfiles = $ENV{'ProgramFiles'};
+}
+my $programfiles = $dosprogramfiles;
+$programfiles =~ s#\\#/#g;
 
+my $mysql   = $programfiles.'/MySQL/MySQL Server 5.1/';
+
 # DOS executable CMD.exe versions of the paths (for when we shell to DOS mode):
 my $dosmsys    = perl2dos($msys);
 my $dossources = perl2dos($sources);
@@ -213,10 +223,11 @@
                            # if you setup mingw right in msys,
                            # so we will usually just say /mingw in the code,
                            # not '.$unixmingw.' or similar (see /etc/fstab)
-my $unixsources = perl2unix($sources);
-my $unixmythtv  = perl2unix($mythtv);
-my $unixhome    = perl2unix($home);
-my $unixbuild   = perl2unix($build);
+my $unixsources      = perl2unix($sources);
+my $unixmythtv       = perl2unix($mythtv);
+my $unixhome         = perl2unix($home);
+my $unixprogramfiles = perl2unix($programfiles);
+my $unixbuild        = perl2unix($build);
 
 # The installer for MinGW:
 my $MinGWinstaller = 'MinGW-5.1.4.exe';
@@ -667,7 +678,7 @@
  [ archive => $sources.'isetup-5.2.3.exe',
      fetch => 'http://files.jrsoftware.org/ispack/ispack-5.2.3.exe',
    comment => 'fetch inno setup setup' ],
- [ file    => "C:/Program Files/Inno Setup 5/iscc.exe",
+ [ file    => $programfiles.'/Inno Setup 5/iscc.exe',
    exec    => $dossources.'isetup-5.2.3.exe', #/silent is broken! 
    comment => 'Install innosetup - install ISTool, '.
               'ISSP, AND encryption support.' ],
@@ -680,15 +691,15 @@
    comment => 'fetching unrar'],
  [ file    => $sources.'bin/unrar.exe',
   shell    => ["cd ".$sources, "unzip/unzip.exe unrar-3.4.3-bin.zip"]],
- [ file    => 'C:/Program Files/Inno Setup 5/UninsHs.exe',
-  shell    => ['cd /c/program\ files/inno\ setup\ 5',
+ [ file    => $programfiles.'/Inno Setup 5/UninsHs.exe',
+  shell    => ['cd "'.$unixprogramfiles.'/inno setup 5"',
               $sources.'bin/unrar.exe e '.$sources.'UninsHs.rar'],
   comment  => 'Install innosetup' ],
  [ archive => $sources.'istool-5.2.1.exe',
      fetch => 'http://downloads.sourceforge.net/sourceforge'.
               '/istool/istool-5.2.1.exe',
    comment => 'fetching istool' ],
- [ file    => "c:/Program Files/ISTool/isxdl.dll",
+ [ file    => $programfiles.'/ISTool/isxdl.dll',
    exec    => $dossources.'istool-5.2.1.exe /silent',
    comment => 'Install istool'],
  [ archive => $sources.'logo_mysql_sun.gif',
@@ -1801,8 +1812,8 @@
 [ grep   => ['SERVICE_NAME',$mythtv.'testmysqlsrv.bat'],
   exec   => ['sc start mysql','nocheck']],
 [ grep   => ['does not exist',$mythtv.'testmysqlsrv.bat'],
-  exec   => ['C:\Program Files\MySQL\MySQL Server 5.1\bin\MySQLd-nt.exe'.
-             ' --standalone  -console','nocheck']],
+  exec   => [$dosprogramfiles.'\MySQL\MySQL Server 5.1\bin\MySQLd-nt.exe '.
+             '--standalone  -console','nocheck']],
 
  
 [ always => [], 
@@ -1811,7 +1822,7 @@
 echo testing connection to a local mysql server...
 sleep 5
 del '.$dosmythtv.'_mysqlshow_err.txt
-"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqlshow.exe" -u mythtv --password=mythtv 2> '.$dosmythtv.'_mysqlshow_err.txt  > '.$dosmythtv.'_mysqlshow_out.txt 
+"'.$dosprogramfiles.'\MySQL\MySQL Server 5.1\bin\mysqlshow.exe" -u mythtv --password=mythtv 2> '.$dosmythtv.'_mysqlshow_err.txt  > '.$dosmythtv.'_mysqlshow_out.txt 
 type '.$dosmythtv.'_mysqlshow_out.txt >> '.$dosmythtv.'_mysqlshow_err.txt 
 del '.$dosmythtv.'_mysqlshow_out.txt
 sleep 1
@@ -1829,7 +1840,7 @@
 # was there, there's no need to reconfigure the server!
 [ grep    => ['(\+--------------------\+|Access denied for user)',
               $mythtv.'_mysqlshow_err.txt'], 
-  exec    => ['C:\Program Files\MySQL\MySQL Server 5.1\bin\MySQLd-nt.exe '.
+  exec    => [$dosprogramfiles.'\MySQL\MySQL Server 5.1\bin\MySQLd-nt.exe '.
               '--standalone  -console', 'nocheck'], 
   comment => 'See if we couldnt connect to a local mysql server. '.
              'Please re-configure the MySQL server to start as a service.'],
@@ -2127,15 +2138,15 @@
       comment => 'Create Packaging directory'],
     # Move required files from inno setup to setup directory
     [ file    => $mythtv."build/isfiles/UninsHs.exe",
-      exec    => 'copy /Y "C:\Program Files\Inno Setup 5\UninsHs.exe" '.
+      exec    => 'copy /Y "'.$dosprogramfiles.'\Inno Setup 5\UninsHs.exe" '.
                  $dosmythtv.'build\isfiles\UninsHs.exe',
       comment => 'Copy UninsHs to setup directory' ],
     [ file    => $mythtv."build/isfiles/isxdl.dll",
-      exec    => 'copy /Y "C:\Program Files\ISTool\isxdl.dll" '.
+      exec    => 'copy /Y "'.$dosprogramfiles.'\ISTool\isxdl.dll" '.
                  $dosmythtv.'build\isfiles\isxdl.dll',
       comment => 'Copy isxdl.dll to setup directory' ],
     [ file    => $mythtv."build/isfiles/WizModernSmallImage-IS.bmp",
-      exec    => 'copy /Y "C:\Program Files\Inno Setup 5'.
+      exec    => 'copy /Y "'.$dosprogramfiles.'\Inno Setup 5'.
                  '\WizModernSmallImage-IS.bmp" '.
                  $dosmythtv.'build\isfiles\WizModernSmallImage-IS.bmp',
       comment => 'Copy WizModernSmallImage-IS.bmp to setup directory' ],
@@ -2175,12 +2186,12 @@
 # Run setup
 #    [ newer   => [$mythtv.'setup/MythTvSetup.exe',
 #                   $mythtv.'mythtv/last_build.txt'],
-#      exec    => ['"c:\Program Files\Inno Setup 5\Compil32.exe" /cc "'.
+#      exec    => ['"'.$dosprogramfiles.'\Inno Setup 5\Compil32.exe" /cc "'.
 #                  $dosmythtv.'build\isfiles\mythtvsetup.iss"' ]],
     [ newer    => [$mythtv.'setup/MythTvSetup.exe',
                     $mythtv.'mythtv/last_build.txt'],
       exec     => ['cd '.$dosmythtv.'build\isfiles && '.
-                   '"c:\Program Files\Inno Setup 5\iscc.exe" "'.
+                   '"'.$dosprogramfiles.'\Inno Setup 5\iscc.exe" "'.
                    $dosmythtv.'build\isfiles\mythtvsetup.iss"' ]],
 
     ;
