I have a Visual Studio Setup Project that creates an MSI to install my application. My application has a shell extension with a icon overlay handler so explorer.exe needs to be restarted in order for the icon overlay handler to start working. I have registered a custom action to run on commit that restarts explorer using the following method:

```cs
public static void restartExplorer()
{
    //stop the shell
    try
    {
       Process process1 = new Process();
       ProcessStartInfo startInfo = new ProcessStartInfo();
       startInfo.WindowStyle = ProcessWindowStyle.Hidden;
       startInfo.FileName = "CMD.exe";
       startInfo.Arguments = "/C \"taskkill /f /im explorer.exe\"";
       process1.StartInfo = startInfo;
       process1.Start();
       do
        {
          Thread.Sleep(100);
          if (process1.HasExited)
          {
               break;
          }
         } while (true);
        }
        catch (Exception e)
        {
            Log.Error("restart explorer", e.StackTrace);
        }

        //restart the shell
        string explorer = string.Format("{0}\\{1}", Environment.GetEnvironmentVariable("WINDIR"), "explorer.exe");
        Process process = new Process();
        process.StartInfo.FileName = explorer;
        process.StartInfo.UseShellExecute = true;
        process.Start();

    }

```

This method works well when I test it from visual studio and call it from command line but when it is called from the MSI during install or uninstall it stops explorer, but does not restart it.

Does anyone know why it would work in all circumstances except when called by the MSI during install or uninstall?

Does anyone have an alternate way to restart the explorer from an MSI during install/uninstall?