>From 6c10d93f716ae1a27ff7dac38e937bc1756b1988 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Mon, 9 Nov 2009 15:04:25 -0700
Subject: [PATCH] Remove old shortcuts must ignore All Users folders
 When removing old shortcuts and program menu folders, ignore files under
 All Users since this is where new installations will put files
 The console shortcuts will no longer open a cmd window - to make them open
 a cmd window (e.g. for debugging) right click on the shortcut, select
 Properties, change Run from Minimized to Normal Window
 Revert back to using the Mondo UI install - no reason to change something
 the user may already be used to (and possibly even use in this mode)

---
 win/Console.wxs |   68 +++++++++++++++++++++++++++++-------------------------
 win/Makefile    |    2 +-
 2 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/win/Console.wxs b/win/Console.wxs
index a247770..c6c6b14 100644
--- a/win/Console.wxs
+++ b/win/Console.wxs
@@ -44,6 +44,7 @@
     <?define Property_Win64 = "no" ?>
     <?define Property_Platform = "Intel" ?>
 <?endif ?>
+<?define EMPTY = "" ?>
 
 <Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
   <Product Name='$(var.PRODUCTNAME)' Id='$(var.PKGGUID)'
@@ -67,13 +68,13 @@
     <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
     <Property Id='DiskPrompt' Value="Console Installation [1]" />
 
-<?ifdef OLDGUID ?>
+<?if $(var.OLDGUID) AND ($(var.OLDGUID) != $(var.EMPTY)) ?>
     <Property Id='OLDGUID' Value="{$(var.OLDGUID)}" />
 <?endif ?>
-<?ifdef OLDSHORTCUT ?>
+<?if $(var.OLDSHORTCUT) AND ($(var.OLDSHORTCUT) != $(var.EMPTY)) ?>
     <Property Id='OLDSHORTCUT' Value="$(var.OLDSHORTCUT)" />
 <?endif ?>
-<?ifdef OLDPROGRAMFOLDER ?>
+<?if $(var.OLDPROGRAMFOLDER) AND ($(var.OLDPROGRAMFOLDER) != $(var.EMPTY)) ?>
     <Property Id='OLDPROGRAMFOLDER' Value="$(var.OLDPROGRAMFOLDER)" />
 <?endif ?>
 
@@ -81,7 +82,7 @@
 
     <CustomAction Id='AlreadyUpdated' Error='[ProductName] [ProductVersion] is already installed.' />
     <CustomAction Id='NoDowngrade' Error='A later version of [ProductName] is already installed.' />
-    <CustomAction Id='RemoveOldPkg' Property='MSIEXEC' ExeCommand='/x [OLDGUID] /qn' Return='asyncNoWait' />
+    <CustomAction Id='RemoveOldPkg' Property='MSIEXEC' ExeCommand='/x [OLDGUID] /qn' Return='ignore' />
     <CustomAction Id='RemoveOldShortcuts' Script='vbscript'>
       <![CDATA[
       On error resume next
@@ -103,25 +104,30 @@
       For Each userfldr in fso.GetFolder(dskfldr).ParentFolder.ParentFolder.SubFolders
         ' for each userfldr
         ' look for Desktop\oldshortcut and remove
-        fullpath = userfldr.path & "\Desktop\" & oldsc
-        If fso.FileExists(fullpath) Then
-          rec.StringData(1) = "RemoveOldShortcuts: Removing old shortcut " & fullpath
-          Session.Message msgtype, rec
-          fso.DeleteFile(fullpath)
-        Else
-          rec.StringData(1) = "RemoveOldShortcuts: ignoring missing old shortcut " & fullpath
-          Session.Message msgtype, rec
-        End If
-        ' look for Start Menu\Programs\oldfldr and remove
-        fullpath = userfldr.path & "\Start Menu\Programs\" & oldfldr
-        If fso.FolderExists(fullpath) Then
-          rec.StringData(1) = "RemoveOldShortcuts: Removing old program folder " & fullpath
-          Session.Message msgtype, rec
-          fso.DeleteFolder(fullpath)
+        If userfldr.name <> "All Users" Then
+          fullpath = userfldr.path & "\Desktop\" & oldsc
+          If fso.FileExists(fullpath) Then
+            rec.StringData(1) = "RemoveOldShortcuts: Removing old shortcut " & fullpath
+            Session.Message msgtype, rec
+            fso.DeleteFile(fullpath)
+          Else
+            rec.StringData(1) = "RemoveOldShortcuts: ignoring missing old shortcut " & fullpath
+            Session.Message msgtype, rec
+          End If
+          ' look for Start Menu\Programs\oldfldr and remove
+          fullpath = userfldr.path & "\Start Menu\Programs\" & oldfldr
+          If fso.FolderExists(fullpath) Then
+            rec.StringData(1) = "RemoveOldShortcuts: Removing old program folder " & fullpath
+            Session.Message msgtype, rec
+            fso.DeleteFolder(fullpath)
+          Else
+            rec.StringData(1) = "RemoveOldShortcuts: ignoring missing old program folder " & fullpath
+            Session.Message msgtype, rec
+          End If
         Else
-          rec.StringData(1) = "RemoveOldShortcuts: ignoring missing old program folder " & fullpath
+          rec.StringData(1) = "RemoveOldShortcuts: skipping folder " & userfldr.name
           Session.Message msgtype, rec
-        End If
+        End If ' not All Users
       Next
       rec.StringData(1) = "RemoveOldShortcuts: End"
       Session.Message msgtype, rec
@@ -232,11 +238,11 @@
           <Component Id='ConsoleBat' Guid='00DEC033-5D77-49a2-9478-FA67E8D4EFEA'>
             <File Id='CONSOLEBAT' LongName='$(var.FILEPREF)-console.bat' Name='con.bat' DiskId='1' src='$(var.FILEPREF)-console.bat' Vital='yes' >
                 <Shortcut Id="startmenuConsole" Directory="ProgramMenuDir" Name="CONFLDR" 
-                  LongName="$(var.SHORTCUT)" WorkingDirectory='INSTALLDIR'
-                  Icon="Logo$(var.BRANDNOSPACE).ico" IconIndex="0" Advertise="yes" />
+                  LongName="$(var.SHORTCUT)" WorkingDirectory='INSTALLDIR' Show="minimized"
+                  Icon="Logo$(var.BRANDNOSPACE).ico" IconIndex="0" />
                 <Shortcut Id="desktopConsole" Directory="DesktopFolder" Name="CONFLDR"
-                  LongName="$(var.SHORTCUT)" WorkingDirectory='INSTALLDIR'
-                  Icon="Logo$(var.BRANDNOSPACE).ico" IconIndex="0" Advertise="yes" />
+                  LongName="$(var.SHORTCUT)" WorkingDirectory='INSTALLDIR' Show="minimized"
+                  Icon="Logo$(var.BRANDNOSPACE).ico" IconIndex="0" />
             </File>
           </Component>
 
@@ -256,11 +262,10 @@
 
     </Directory>
 
-    <Feature Id='Complete' Title='$(var.PRODUCTNAME)' Description='The complete package.'
-      TypicalDefault='install' Display='expand' Level='1'
-      ConfigurableDirectory='INSTALLDIR'>
+    <Feature Id='Complete' Title='$(var.PRODUCTNAME)' Description='The complete package.' Display='expand'
+      Level='1' ConfigurableDirectory='INSTALLDIR'>
       <Feature Id='MainProgram' Title='Program' Description='The main executable.'
-        TypicalDefault='install' Level='1'>
+        Level='1'>
 	    <ComponentRef Id='NSPRLibrary' />
 	    <ComponentRef Id='NSPRpldsLibrary' />
 	    <ComponentRef Id='NSPRplcLibrary' />
@@ -295,14 +300,13 @@
 
     <Property Id="INSTALLLEVEL">3</Property>
 
-    <!-- we don't really allow fancy dialogs and customization, so just use minimal -->
-    <UIRef Id="WixUI_Minimal" />
+    <UIRef Id="WixUI_Mondo" />
     <UIRef Id="WixUI_ErrorProgressText" />
 
     <InstallExecuteSequence>
       <Custom Action='NoDowngrade' After='FindRelatedProducts'>NEWERFOUND</Custom>
       <RemoveExistingProducts After='InstallFinalize' />
-      <Custom Action='RemoveOldPkg' After='InstallFinalize'>OLDGUID AND NOT Installed</Custom>
+      <Custom Action='RemoveOldPkg' After='RemoveExistingProducts'>OLDGUID AND NOT Installed</Custom>
       <Custom Action='RemoveOldShortcuts' After='RemoveOldPkg'>OLDSHORTCUT AND OLDPROGRAMFOLDER AND NOT Installed</Custom>
     </InstallExecuteSequence>
 
diff --git a/win/Makefile b/win/Makefile
index 9982eb4..c381a21 100644
--- a/win/Makefile
+++ b/win/Makefile
@@ -172,7 +172,7 @@ $(CONSOLEDIR)\$(FILEPREF)-console_en.jar : $(CONSOLEDIR)
 $(WIXDIR)\wix-$(WIXVER).zip : $(WIXDIR)
 	if not exist $@ $(DOWNLOAD) $(WIXURL)/$(@F) %%CD%%\$@
 
-$(CANDLE) : $(WIXDIR)\wix-$(WIXVER).zip
+$(PKGDIR)\$(CANDLE) : $(WIXDIR)\wix-$(WIXVER).zip
 	$(UZCMD) $? -d $(?D)
 
 LAYOUT : $(PKGDIR) $(NSPRLIBDIR)\libnspr4.dll $(NSSLIBDIR)\nss3.dll $(JSSDIR)\jss4.dll $(JSSDIR)\jss4.jar $(LDAPDIR)\ldapjdk.jar $(IDMDIR)\idm-console-base.jar $(IDMDIR)\idm-console-mcc.jar $(IDMDIR)\idm-console-mcc_en.jar $(IDMDIR)\idm-console-nmclf.jar $(IDMDIR)\idm-console-nmclf_en.jar $(CONSOLEDIR)\$(FILEPREF)-console_en.jar
-- 
1.5.6.1.1071.g76fb

