public void LaunchProgram(ApplicationInfo app) { if (app == null) { return; } // so that we only prompt to always run as admin if it's done consecutively if (app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; Save(); } if (app.AllowRunAsAdmin && app.AlwaysAdmin) { LaunchProgramVerb(app, "runas"); } else if (EnvironmentHelper.IsAppRunningAsShell && app.Target.ToLower().EndsWith("explorer.exe")) { // special case: if we are shell and launching explorer, give it a parameter so that it doesn't do shell things. if (!ShellHelper.StartProcess(app.Path, ShellFolderPath.ComputerFolder.Value)) { CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } } else if (!ShellHelper.StartProcess(app.Path, workingDirectory: getAppParentDirectory(app))) { CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } }
/* Helper methods */ public void LaunchProgram(ApplicationInfo app) { if (app != null) { // so that we only prompt to always run as admin if it's done consecutively if (app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; Save(); } if (!app.IsStoreApp && app.AlwaysAdmin) { Shell.StartProcess(app.Path, "", "runas"); } else if (Shell.IsCairoRunningAsShell && app.Target.ToLower().EndsWith("explorer.exe")) { // special case: if we are shell and launching explorer, give it a parameter so that it doesn't do shell things. // this opens My Computer if (!Shell.StartProcess(app.Path, "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } } else if (!Shell.StartProcess(app.Path)) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } } }
public void LaunchProgramAdmin(ApplicationInfo app) { if (app != null) { if (!app.IsStoreApp) { if (!app.AlwaysAdmin) { if (app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; bool?always = CairoMessage.Show(String.Format(Localization.DisplayString.sProgramsMenu_AlwaysAdminInfo, app.Name), Localization.DisplayString.sProgramsMenu_AlwaysAdminTitle, MessageBoxButton.YesNo, MessageBoxImage.Question); if (always == true) { app.AlwaysAdmin = true; } } else { app.AskAlwaysAdmin = true; } Save(); } Shell.StartProcess(app.Path, "", "runas"); } else { LaunchProgram(app); } } }
public void LaunchProgramVerb(ApplicationInfo app, string verb) { if (!Shell.StartProcess(app.Path, "", verb)) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void ExecuteOpenSearchResult(object sender, ExecutedRoutedEventArgs e) { var searchObj = (SearchResult)e.Parameter; if (!Shell.StartProcess(searchObj.Path)) { CairoMessage.Show(Localization.DisplayString.sSearch_Error, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void LaunchProgramVerb(ApplicationInfo app, string verb) { if (app != null) { if (!ShellHelper.StartProcess(app.Path, "", verb)) { CairoMessage.Show(DisplayString.sError_FileNotFoundInfo, DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } } }
public static void ShowAppProperties(ApplicationInfo app) { if (app != null) { if (app.IsStoreApp) { CairoMessage.Show(Localization.DisplayString.sProgramsMenu_UWPInfo, app.Name, app.GetIconImageSource(IconSize.Jumbo, false), true); } else { Shell.ShowFileProperties(app.Path); } } }
private void MenuItem_OnClick(object sender, RoutedEventArgs e) { if (sender is MenuItem menuItem) { if (menuItem.CommandParameter is ManagedShell.Common.SupportingClasses.SearchResult searchObj) { if (!ShellHelper.StartProcess(searchObj.Path)) { CairoMessage.Show(Localization.DisplayString.sSearch_Error, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, CairoMessageImage.Error); } } } }
public void ShowAppProperties(ApplicationInfo app) { if (app == null) { return; } if (app.IsStoreApp) { CairoMessage.Show(DisplayString.sProgramsMenu_UWPInfo, app.Name, app.GetIconImageSource(IconSize.Jumbo), true); } else { ShellHelper.ShowFileProperties(app.Path); } }
/* Helper methods */ public void LaunchProgram(ApplicationInfo app) { // so that we only prompt to always run as admin if it's done consecutively if (app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; Save(); } if (!app.IsStoreApp && app.AlwaysAdmin) { Shell.StartProcess(app.Path, "", "runas"); } else if (!Shell.StartProcess(app.Path)) { CairoMessage.Show(Localization.DisplayString.sError_FileNotFoundInfo, Localization.DisplayString.sError_OhNo, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void LaunchProgramAdmin(ApplicationInfo app) { if (app != null) { if (!app.IsStoreApp) { if (!app.AlwaysAdmin) { if (app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; CairoMessage.Show(string.Format(DisplayString.sProgramsMenu_AlwaysAdminInfo, app.Name), DisplayString.sProgramsMenu_AlwaysAdminTitle, MessageBoxButton.YesNo, CairoMessageImage.Information, result => { if (result == true) { app.AlwaysAdmin = true; } }); } else { app.AskAlwaysAdmin = true; } Save(); } ShellHelper.StartProcess(app.Path, "", "runas"); } else { LaunchProgram(app); } } }
public void LaunchProgramAdmin(ApplicationInfo app) { if (app == null) { return; } if (!app.AllowRunAsAdmin) { LaunchProgram(app); return; } if (!app.AlwaysAdmin && app.AskAlwaysAdmin) { app.AskAlwaysAdmin = false; Save(); CairoMessage.Show(string.Format(DisplayString.sProgramsMenu_AlwaysAdminInfo, app.Name), DisplayString.sProgramsMenu_AlwaysAdminTitle, MessageBoxButton.YesNo, CairoMessageImage.Information, result => { if (result == true) { app.AlwaysAdmin = true; Save(); } }); } else if (!app.AlwaysAdmin) { app.AskAlwaysAdmin = true; Save(); } LaunchProgramVerb(app, "runas"); }