private static void Execute(string scriptFile) { shell = new GraphicalShell(); shell.StartShell(new RunnerRunspaceConfigurationFactory()); shell.MoveBufferWindowPosition(0, 0); var baobabProperties = new Hashtable(); baobabProperties["OpenWindow"] = false; shell.SetVariable("BaobabShell", baobabProperties); var cmd = new CommandInfo(scriptFile, null) { WriteDecorations = true, LocalScope = true }; shell.InvokeSync(cmd); var openWindow = baobabProperties["OpenWindow"] is bool ? (bool)baobabProperties["OpenWindow"] : false; var ui = (BaseUI)shell.Host.UI; if (openWindow || ui.WarningWritten || ui.ErrorWritten) { var form = new ShellDialog(shell); Application.Run(form); } }