public static void Start(RunItem item, bool asAdmin, bool openContainingFolder) { try { //Fire away. We don't need to hold on to it... Task.Run(() => { switch (item.Type) { case ItemType.File: if (asAdmin) { WindowHelper.BringProcessToFrontOrStartIt(item.URI, item.Arguments, asAdmin: true); } else if (openContainingFolder) { string args = $"/e, /select, \"{item.URI}\""; ProcessStartInfo info = new ProcessStartInfo { FileName = "explorer", Arguments = args }; Process.Start(info); } else //The normal start { WindowHelper.BringProcessToFrontOrStartIt(item.URI, item.Arguments, asAdmin: false); } break; case ItemType.Link: if (asAdmin) { WindowHelper.BringProcessToFrontOrStartIt(item.Command, item.Arguments, asAdmin: true); } else if (openContainingFolder) { string args = $"/e, /select, \"{item.URI}\""; ProcessStartInfo info = new ProcessStartInfo { FileName = "explorer", Arguments = args }; Process.Start(info); } else //The normal start { WindowHelper.BringProcessToFrontOrStartIt(item.Command, item.Arguments, asAdmin: false); } break; case ItemType.Directory: Process.Start(item.URI); break; case ItemType.Win10App: StartWin10App(item); break; case ItemType.RunDialog: RunFileDlg(IntPtr.Zero, IntPtr.Zero, null, null, null, 0); break; case ItemType.ControlPanelSetting: Process.Start(item.Command); break; case ItemType.TurnOffComputer: Process.Start("shutdown", "/s /t 0"); break; case ItemType.RestartComputer: Process.Start("shutdown", "/r /t 0"); // the argument /r is to restart the computer break; case ItemType.LogOffComputer: ExitWindowsEx(0, 0); break; case ItemType.LockComputer: LockWorkStation(); break; case ItemType.Hibernate: SetSuspendState(true, true, true); break; case ItemType.Sleep: SetSuspendState(false, true, true); break; } }); } catch (Exception e) { Log.Error(e, "Could not execute this command"); } }