mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
common helper for execute shell process from run plugins (#9538)
This commit is contained in:
committed by
GitHub
parent
20a922ce21
commit
571bceb386
@@ -4,8 +4,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO.Abstractions;
|
||||
using System.Linq;
|
||||
@@ -16,6 +14,7 @@ using Microsoft.Plugin.Indexer.DriveDetection;
|
||||
using Microsoft.Plugin.Indexer.SearchHelper;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Microsoft.Search.Interop;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.Logger;
|
||||
@@ -85,15 +84,7 @@ namespace Microsoft.Plugin.Indexer
|
||||
IcoPath = WarningIconPath,
|
||||
Action = e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(GetWindowsSearchSettingsProcessInfo());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Exception($"Unable to launch Windows Search Settings: {ex.Message}", ex, GetType());
|
||||
}
|
||||
|
||||
Helper.OpenInShell("ms-settings:cortana-windowssearch");
|
||||
return true;
|
||||
},
|
||||
});
|
||||
@@ -129,23 +120,13 @@ namespace Microsoft.Plugin.Indexer
|
||||
r.ToolTipData = new ToolTipData(toolTipTitle, toolTipText);
|
||||
r.Action = c =>
|
||||
{
|
||||
bool hide;
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = path,
|
||||
UseShellExecute = true,
|
||||
WorkingDirectory = workingDir,
|
||||
});
|
||||
hide = true;
|
||||
}
|
||||
catch (Win32Exception)
|
||||
bool hide = true;
|
||||
if (!Helper.OpenInShell(path, null, workingDir))
|
||||
{
|
||||
hide = false;
|
||||
var name = $"Plugin: {_context.CurrentPluginMetadata.Name}";
|
||||
var msg = Properties.Resources.Microsoft_plugin_indexer_file_open_failed;
|
||||
_context.API.ShowMsg(name, msg, string.Empty);
|
||||
hide = false;
|
||||
}
|
||||
|
||||
return hide;
|
||||
@@ -239,18 +220,6 @@ namespace Microsoft.Plugin.Indexer
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// Returns the Process Start Information for the new Windows Search Settings
|
||||
public static ProcessStartInfo GetWindowsSearchSettingsProcessInfo()
|
||||
{
|
||||
var ps = new ProcessStartInfo("ms-settings:cortana-windowssearch")
|
||||
{
|
||||
UseShellExecute = true,
|
||||
Verb = "open",
|
||||
};
|
||||
|
||||
return ps;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
|
||||
Reference in New Issue
Block a user