mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PowerToys Run] Issues with elevation (#11775)
* Delegate creation of non elevated process * Error handling * nits * Fix potential race condition * Fix spelling * Fix spelling * Fix build
This commit is contained in:
@@ -44,12 +44,18 @@ namespace PowerLauncher.Helper
|
||||
/// Suffix to the channel name.
|
||||
/// </summary>
|
||||
private const string ChannelNameSuffix = "SingeInstanceIPCChannel";
|
||||
private const string InstanceMutexName = @"Local\PowerToys_Run_InstanceMutex";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets application mutex.
|
||||
/// </summary>
|
||||
internal static Mutex SingleInstanceMutex { get; set; }
|
||||
|
||||
internal static void CreateInstanceMutex()
|
||||
{
|
||||
SingleInstanceMutex = new Mutex(true, InstanceMutexName, out bool firstInstance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the instance of the application attempting to start is the first instance.
|
||||
/// If not, activates the first instance.
|
||||
@@ -57,14 +63,12 @@ namespace PowerLauncher.Helper
|
||||
/// <returns>True if this is the first instance of the application.</returns>
|
||||
internal static bool InitializeAsFirstInstance()
|
||||
{
|
||||
string mutexName = @"Local\PowerToys_Run_InstanceMutex";
|
||||
|
||||
// Build unique application Id and the IPC channel name.
|
||||
string applicationIdentifier = mutexName + Environment.UserName;
|
||||
string applicationIdentifier = InstanceMutexName + Environment.UserName;
|
||||
|
||||
string channelName = string.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix);
|
||||
|
||||
SingleInstanceMutex = new Mutex(true, mutexName, out bool firstInstance);
|
||||
SingleInstanceMutex = new Mutex(true, InstanceMutexName, out bool firstInstance);
|
||||
if (firstInstance)
|
||||
{
|
||||
_ = CreateRemoteService(channelName);
|
||||
|
||||
Reference in New Issue
Block a user