Issue #27888: Prevent Windows installer from displaying console windows and failing when pip cannot be installed/uninstalled.
diff --git a/Tools/msi/WixCA.blob b/Tools/msi/WixCA.blob
new file mode 100644
index 0000000..171d309
--- /dev/null
+++ b/Tools/msi/WixCA.blob
Binary files differ
diff --git a/Tools/msi/msi.py b/Tools/msi/msi.py
index 3ef4a65..1c2fdfa 100644
--- a/Tools/msi/msi.py
+++ b/Tools/msi/msi.py
@@ -376,6 +376,7 @@
     # the installed/uninstalled state according to both the
     # Extensions and TclTk features.
     add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
+    add_data(db, "Binary", [("WixCA", msilib.Binary("WixCA.blob"))])
     # See "Custom Action Type 1"
     if msilib.Win64:
         CheckDir = "CheckDir"
@@ -407,10 +408,11 @@
               ("VerdanaRed9", "Verdana", 9, 255, 0),
              ])
 
-    compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x "bad_coding|badsyntax|site-packages|py3_" "[TARGETDIR]Lib"'
-    lib2to3args = r'-c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"'
-    updatepipargs = r'-m ensurepip -U --default-pip'
-    removepipargs = r'-B -m ensurepip._uninstall'
+    compileargs = r'"[#python.exe]" -Wi "[TARGETDIR]Lib\compileall.py" -f -x "bad_coding|badsyntax|site-packages|py3_" "[TARGETDIR]Lib"'
+    compileoargs = r'"[#python.exe]" -O -Wi "[TARGETDIR]Lib\compileall.py" -f -x "bad_coding|badsyntax|site-packages|py3_" "[TARGETDIR]Lib"'
+    lib2to3args = r'"[#python.exe]" -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"'
+    updatepipargs = r'"[#python.exe]" -m ensurepip -U --default-pip'
+    removepipargs = r'"[#python.exe]" -B -m ensurepip._uninstall'
     # See "CustomAction Table"
     add_data(db, "CustomAction", [
         # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
@@ -424,11 +426,16 @@
         # See "Custom Action Type 18"
         # msidbCustomActionTypeInScript (1024); run during actual installation
         # msidbCustomActionTypeNoImpersonate (2048); run action in system account, not user account
-        ("CompilePyc", 18+1024+2048, "python.exe", compileargs),
-        ("CompilePyo", 18+1024+2048, "python.exe", "-O "+compileargs),
-        ("CompileGrammar", 18+1024+2048, "python.exe", lib2to3args),
-        ("UpdatePip", 18+1024+2048, "python.exe", updatepipargs),
-        ("RemovePip", 18+1024+2048, "python.exe", removepipargs),
+        ("SetCompilePycCommandLine", 51, "CompilePyc", compileargs),
+        ("SetCompilePyoCommandLine", 51, "CompilePyo", compileoargs),
+        ("SetCompileGrammarCommandLine", 51, "CompileGrammar", lib2to3args),
+        ("CompilePyc", 1+64+1024, "WixCA", "CAQuietExec"),
+        ("CompilePyo", 1+64+1024, "WixCA", "CAQuietExec"),
+        ("CompileGrammar", 1+64+1024, "WixCA", "CAQuietExec"),
+        ("SetUpdatePipCommandLine", 51, "UpdatePip", updatepipargs),
+        ("UpdatePip", 1+64+1024, "WixCA", "CAQuietExec"),
+        ("SetRemovePipCommandLine", 51, "RemovePip", removepipargs),
+        ("RemovePip", 1+64+1024, "WixCA", "CAQuietExec"),
         ])
 
     # UI Sequences, see "InstallUISequence Table", "Using a Sequence Table"
@@ -460,15 +467,20 @@
              ("SetDLLDirToSystem32", 'DLLDIR="" and ' + sys32cond, 751),
              ("SetDLLDirToTarget", 'DLLDIR="" and not ' + sys32cond, 752),
              ("UpdateEditIDLE", None, 1050),
-             # run command if install state of pip changes to INSTALLSTATE_LOCAL
-             # run after InstallFiles
-             ("UpdatePip", "&pip_feature=3", 4001),
              # remove pip when state changes to INSTALLSTATE_ABSENT
              # run before RemoveFiles
-             ("RemovePip", "&pip_feature=2", 3499),
-             ("CompilePyc", "COMPILEALL", 4002),
-             ("CompilePyo", "COMPILEALL", 4003),
-             ("CompileGrammar", "COMPILEALL", 4004),
+             ("SetRemovePipCommandLine", "&pip_feature=2 and !pip_feature=3", 3498),
+             ("RemovePip", "RemovePip", 3499),
+             # run command if install state of pip changes to INSTALLSTATE_LOCAL
+             # run after InstallFiles
+             ("SetUpdatePipCommandLine", "&pip_feature=3 and not !pip_feature=3", 4001),
+             ("UpdatePip", "UpdatePip", 4002),
+             ("SetCompilePycCommandLine", "COMPILEALL", 4003),
+             ("SetCompilePyoCommandLine", "COMPILEALL", 4004),
+             ("SetCompileGrammarCommandLine", "COMPILEALL", 4005),
+             ("CompilePyc", "CompilePyc", 4006),
+             ("CompilePyo", "CompilePyo", 4007),
+             ("CompileGrammar", "CompileGrammar", 4008),
             ])
     add_data(db, "AdminExecuteSequence",
             [("InitialTargetDir", 'TARGETDIR=""', 750),