Amazon.KinesisTap.AutoUpdate/PackageUpdater.cs
/// <summary>
/// Use Process to execute PowerShell.exe. The script will restart KinesisTap
/// </summary>
/// <param name="installScriptPath"></param>
Use Process to execute PowerShell.exe. The script will restart KinesisTap
Use Process to execute PowerShell . exe . The script will restart KinesisTap
private async Task ExecutePowershellOutOfProcessAsync(string installScriptPath)
        {
            try
            {
                Process process = new Process();
                process.StartInfo.FileName = "PowerShell.exe";
                process.StartInfo.Arguments = $"-File {installScriptPath}";
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.Start();
                while (!process.HasExited)
                {
                    const int timeout = 2000;
                    var outputTask = PipeOutputAsync(process);
                    if (await Task.WhenAny(outputTask, Task.Delay(timeout)) == outputTask)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch(Exception ex)
            {
                _context.Logger?.LogError($"Error starting powershell script: {ex.ToMinimized()}");
            }
        }
private async Task ExecutePowershellOutOfProcessAsync ( string installScriptPath ) { try { Process process = new Process ( ) ; process . StartInfo . FileName = " " ; process . StartInfo . Arguments = $" -File  { installScriptPath } " ; process . StartInfo . UseShellExecute = false ; process . StartInfo . RedirectStandardOutput = true ; process . Start ( ) ; while ( ! process . HasExited ) { const int timeout = 2000 ; var outputTask = PipeOutputAsync ( process ) ; if ( await Task . WhenAny ( outputTask , Task . Delay ( timeout ) ) == outputTask ) { continue ; } else { break ; } } } catch ( Exception ex ) { _context . Logger ? . LogError ( $" Error starting powershell script:  { ex . ToMinimized ( ) } " ) ; } }
Use Process to execute PowerShell.exe.
Use Process to execute PowerShell . exe .
//The following code will pipe the output of the Powershell to KinesisTap for up to 2 second //Then it will exit because it sometimes interfere with service restart
installScriptPath
string
None