Fix admin launch and settings visibility
This commit is contained in:
@@ -115,8 +115,8 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="16"/>
|
<RowDefinition Height="16"/>
|
||||||
<RowDefinition Height="Auto"/>
|
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Border Background="{DynamicResource AppPanelBrush}"
|
<Border Background="{DynamicResource AppPanelBrush}"
|
||||||
@@ -159,8 +159,10 @@
|
|||||||
|
|
||||||
<Separator Grid.Row="1" VerticalAlignment="Center"/>
|
<Separator Grid.Row="1" VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<Border Grid.Row="2"
|
<ScrollViewer Grid.Row="2"
|
||||||
Background="{DynamicResource AppPanelBrush}"
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Disabled">
|
||||||
|
<Border Background="{DynamicResource AppPanelBrush}"
|
||||||
BorderBrush="{DynamicResource AppBorderBrush}"
|
BorderBrush="{DynamicResource AppBorderBrush}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
CornerRadius="12"
|
CornerRadius="12"
|
||||||
@@ -236,6 +238,7 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
<TextBlock x:Name="StatusText" Grid.Row="3" Margin="4,14,4,0"
|
<TextBlock x:Name="StatusText" Grid.Row="3" Margin="4,14,4,0"
|
||||||
Foreground="{DynamicResource AppMutedTextBrush}"
|
Foreground="{DynamicResource AppMutedTextBrush}"
|
||||||
|
|||||||
@@ -276,18 +276,20 @@ public sealed class LauncherController : IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
string target = Environment.ExpandEnvironmentVariables(item.Target);
|
string target = Environment.ExpandEnvironmentVariables(item.Target);
|
||||||
|
bool runAsAdmin = item.RunAsAdmin && CanRunAsAdmin(item.Type);
|
||||||
|
string launchTarget = runAsAdmin ? ResolveExecutableTarget(target) : target;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProcessStartInfo startInfo = new()
|
ProcessStartInfo startInfo = new()
|
||||||
{
|
{
|
||||||
FileName = target,
|
FileName = launchTarget,
|
||||||
Arguments = item.Arguments ?? "",
|
Arguments = item.Arguments ?? "",
|
||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
WorkingDirectory = Directory.Exists(target) ? target : ConfigService.AppFolder
|
WorkingDirectory = Directory.Exists(target) ? target : ConfigService.AppFolder
|
||||||
};
|
};
|
||||||
|
|
||||||
if (item.RunAsAdmin && CanRunAsAdmin(item.Type))
|
if (runAsAdmin)
|
||||||
{
|
{
|
||||||
startInfo.Verb = "runas";
|
startInfo.Verb = "runas";
|
||||||
}
|
}
|
||||||
@@ -306,4 +308,32 @@ public sealed class LauncherController : IDisposable
|
|||||||
{
|
{
|
||||||
return itemType is LauncherItemType.App or LauncherItemType.File;
|
return itemType is LauncherItemType.App or LauncherItemType.File;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string ResolveExecutableTarget(string target)
|
||||||
|
{
|
||||||
|
if (Path.IsPathRooted(target) || Path.GetDirectoryName(target) is { Length: > 0 })
|
||||||
|
{
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] searchFolders =
|
||||||
|
[
|
||||||
|
Environment.CurrentDirectory,
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.Windows),
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.System),
|
||||||
|
.. (Environment.GetEnvironmentVariable("PATH") ?? "")
|
||||||
|
.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (string folder in searchFolders.Where(Directory.Exists).Distinct(StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
string candidate = Path.Combine(folder, target);
|
||||||
|
if (File.Exists(candidate))
|
||||||
|
{
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
<Authors>Ray Berezowski</Authors>
|
<Authors>Ray Berezowski</Authors>
|
||||||
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.0.1</Version>
|
||||||
<AssemblyVersion>1.0.1.18</AssemblyVersion>
|
<AssemblyVersion>1.0.1.19</AssemblyVersion>
|
||||||
<FileVersion>1.0.1.18</FileVersion>
|
<FileVersion>1.0.1.19</FileVersion>
|
||||||
<InformationalVersion>1.0.1</InformationalVersion>
|
<InformationalVersion>1.0.1</InformationalVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user