Fix admin launch and settings visibility
This commit is contained in:
@@ -115,8 +115,8 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="16"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border Background="{DynamicResource AppPanelBrush}"
|
||||
@@ -159,8 +159,10 @@
|
||||
|
||||
<Separator Grid.Row="1" VerticalAlignment="Center"/>
|
||||
|
||||
<Border Grid.Row="2"
|
||||
Background="{DynamicResource AppPanelBrush}"
|
||||
<ScrollViewer Grid.Row="2"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled">
|
||||
<Border Background="{DynamicResource AppPanelBrush}"
|
||||
BorderBrush="{DynamicResource AppBorderBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
@@ -236,6 +238,7 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ScrollViewer>
|
||||
|
||||
<TextBlock x:Name="StatusText" Grid.Row="3" Margin="4,14,4,0"
|
||||
Foreground="{DynamicResource AppMutedTextBrush}"
|
||||
|
||||
@@ -276,18 +276,20 @@ public sealed class LauncherController : IDisposable
|
||||
}
|
||||
|
||||
string target = Environment.ExpandEnvironmentVariables(item.Target);
|
||||
bool runAsAdmin = item.RunAsAdmin && CanRunAsAdmin(item.Type);
|
||||
string launchTarget = runAsAdmin ? ResolveExecutableTarget(target) : target;
|
||||
|
||||
try
|
||||
{
|
||||
ProcessStartInfo startInfo = new()
|
||||
{
|
||||
FileName = target,
|
||||
FileName = launchTarget,
|
||||
Arguments = item.Arguments ?? "",
|
||||
UseShellExecute = true,
|
||||
WorkingDirectory = Directory.Exists(target) ? target : ConfigService.AppFolder
|
||||
};
|
||||
|
||||
if (item.RunAsAdmin && CanRunAsAdmin(item.Type))
|
||||
if (runAsAdmin)
|
||||
{
|
||||
startInfo.Verb = "runas";
|
||||
}
|
||||
@@ -306,4 +308,32 @@ public sealed class LauncherController : IDisposable
|
||||
{
|
||||
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>
|
||||
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
||||
<Version>1.0.1</Version>
|
||||
<AssemblyVersion>1.0.1.18</AssemblyVersion>
|
||||
<FileVersion>1.0.1.18</FileVersion>
|
||||
<AssemblyVersion>1.0.1.19</AssemblyVersion>
|
||||
<FileVersion>1.0.1.19</FileVersion>
|
||||
<InformationalVersion>1.0.1</InformationalVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user