/// <summary> /// Get services to web page /// </summary> public static async Task <(bool, Exception)> GetServicesAsHtml() { string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "service.html"); if (File.Exists(fileName)) { File.Delete(fileName); } var start = new ProcessStartInfo { FileName = "powershell.exe", UseShellExecute = false, RedirectStandardOutput = true, Arguments = "Get-Service | Select-Object Name, DisplayName, @{ n='Status'; e={ $_.Status.ToString() } }, @{ n='table'; e={ 'Status' } } | ConvertTo-html", CreateNoWindow = true }; using var process = Process.Start(start); using var reader = process.StandardOutput; process.EnableRaisingEvents = true; var fileContents = await reader.ReadToEndAsync(); await File.WriteAllTextAsync(fileName, fileContents); await process.WaitForExitAsync(); try { ChromeLauncher.OpenLink(fileName); return(true, null); } catch (Exception ex) { return(false, ex); } }
private void StartBrowser(string url) { this._WebBrowserExtendedState = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserAcquiring; ChromeLauncher cl = new ChromeLauncher(); _Process = cl.OpenLink(url); if (_Process == null) { throw new Exception("Unable to attach to browser. Protected Mode may be disable"); } _webBrowser = cl.ChromeWindow; this._Process.Exited += _Process_Exited; this._Process.EnableRaisingEvents = true; this._WebBrowserExtendedState = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserAcquired; if (_webBrowser != IntPtr.Zero) { ManipulateWindow(); } else { browserAquiredStart = DateTime.Now; browserAquiredTimer = new System.Threading.Timer(new TimerCallback(BrowserAquiredCheck), null, TimeSpan.FromMilliseconds(300), TimeSpan.Zero); } }