Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions SysManager/SysManager/ViewModels/ServicesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public sealed partial class ServicesViewModel : ViewModelBase

public BulkObservableCollection<ServiceEntry> Services { get; } = new();

[ObservableProperty] private bool _isElevated;
[ObservableProperty] private string _filter = "";
[ObservableProperty] private string _selectedFilter = "All";
[ObservableProperty] private ServiceEntry? _selectedService;
Expand All @@ -37,9 +38,17 @@ public sealed partial class ServicesViewModel : ViewModelBase
public ServicesViewModel(PowerShellRunner ps)
{
_ps = ps;
IsElevated = AdminHelper.IsElevated();
InitializeAsync(InitAsync);
}

[RelayCommand]
private void RelaunchElevated()
{
if (AdminHelper.RelaunchAsAdmin())
System.Windows.Application.Current?.Shutdown();
}
Comment on lines +45 to +50
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add explicit feedback when elevation relaunch does not succeed.

At Line 48, only the success path is handled. If UAC is canceled or relaunch fails, users get no status update. Set a failure/cancel StatusMessage in the else path so the button outcome is clear.

Suggested patch
 [RelayCommand]
 private void RelaunchElevated()
 {
     if (AdminHelper.RelaunchAsAdmin())
         System.Windows.Application.Current?.Shutdown();
+    else
+        StatusMessage = "Elevation request canceled or failed.";
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[RelayCommand]
private void RelaunchElevated()
{
if (AdminHelper.RelaunchAsAdmin())
System.Windows.Application.Current?.Shutdown();
}
[RelayCommand]
private void RelaunchElevated()
{
if (AdminHelper.RelaunchAsAdmin())
System.Windows.Application.Current?.Shutdown();
else
StatusMessage = "Elevation request canceled or failed.";
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@SysManager/SysManager/ViewModels/ServicesViewModel.cs` around lines 45 - 50,
RelaunchElevated only handles the success case and leaves users uninformed when
AdminHelper.RelaunchAsAdmin() returns false; modify RelaunchElevated to add an
else branch that sets the view model's StatusMessage (or similar existing status
property) to a clear failure/cancel message when RelaunchAsAdmin() returns false
so users receive explicit feedback about the canceled/failed elevation attempt;
reference the RelaunchElevated method, the AdminHelper.RelaunchAsAdmin() call,
and the StatusMessage property when making the change.


private async Task InitAsync()
{
try { await RefreshAsync(); }
Expand Down
22 changes: 16 additions & 6 deletions SysManager/SysManager/Views/DnsHostsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,32 @@
Style="{StaticResource Subtle}" Margin="0,4,0,0"/>
</StackPanel>

<!-- Elevation banner -->
<!-- Elevation banner: not elevated -->
<Border Grid.Row="1" Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="28,12,28,0"
BorderThickness="1" CornerRadius="8" Padding="14,12" Margin="28,12,28,0"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<DockPanel>
<Button Content="Run as administrator" Command="{Binding RelaunchElevatedCommand}"
Style="{StaticResource SecondaryButton}" DockPanel.Dock="Right" Padding="12,6"/>
Style="{StaticResource PrimaryButton}" DockPanel.Dock="Right" Padding="14,8"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="&#xE83D;" FontFamily="Segoe Fluent Icons,Segoe MDL2 Assets"
FontSize="14" Margin="0,0,8,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Administrator privileges required to change DNS and edit the hosts file."
Style="{StaticResource Subtle}" VerticalAlignment="Center"/>
FontSize="16" Margin="0,0,10,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Changing DNS and editing the hosts file requires administrator privileges."
Foreground="{StaticResource TextSecondary}" FontSize="13" VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Border>

<!-- Elevation banner: elevated -->
<Border Grid.Row="1" Background="#0D1F12" BorderBrush="#22C55E44" BorderThickness="1"
CornerRadius="8" Padding="10,8" Margin="28,12,28,0"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}}">
<StackPanel Orientation="Horizontal">
<Ellipse Width="8" Height="8" Fill="#22C55E" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="Running as administrator — you can change DNS settings and edit the hosts file." Foreground="#22C55E" FontSize="13" FontWeight="Medium"/>
</StackPanel>
</Border>

<!-- DNS Section -->
<Border Grid.Row="2" Style="{StaticResource Card}" Margin="28,16,28,0">
<StackPanel>
Expand Down
26 changes: 18 additions & 8 deletions SysManager/SysManager/Views/PrivacyView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,32 @@
</WrapPanel>
</Border>

<!-- Elevation info strip (shown when not running as admin) -->
<Border Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="0,0,0,12"
Grid.Row="2" Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<!-- Elevation banner: not elevated -->
<Border Grid.Row="2" Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="14,12" Margin="0,0,0,12"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<DockPanel>
<Button Content="Run as administrator" Command="{Binding RelaunchElevatedCommand}"
Style="{StaticResource SecondaryButton}" DockPanel.Dock="Right" Padding="12,6"/>
Style="{StaticResource PrimaryButton}" DockPanel.Dock="Right" Padding="14,8"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="&#xE83D;" FontFamily="Segoe Fluent Icons,Segoe MDL2 Assets"
FontSize="14" Margin="0,0,8,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Some settings require administrator privileges to change."
Style="{StaticResource Subtle}" VerticalAlignment="Center"/>
FontSize="16" Margin="0,0,10,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Some privacy settings write to system-wide registry keys and require administrator privileges."
Foreground="{StaticResource TextSecondary}" FontSize="13" VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Border>

<!-- Elevation banner: elevated -->
<Border Grid.Row="2" Background="#0D1F12" BorderBrush="#22C55E44" BorderThickness="1"
CornerRadius="8" Padding="10,8" Margin="0,0,0,12"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}}">
<StackPanel Orientation="Horizontal">
<Ellipse Width="8" Height="8" Fill="#22C55E" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="Running as administrator — all privacy toggles are available." Foreground="#22C55E" FontSize="13" FontWeight="Medium"/>
</StackPanel>
</Border>

<!-- Toggle list grouped by category -->
<Border Grid.Row="3" Style="{StaticResource Card}" Padding="0">
<ScrollViewer VerticalScrollBarVisibility="Auto" Padding="16,12">
Expand Down
31 changes: 29 additions & 2 deletions SysManager/SysManager/Views/ServicesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<Grid Margin="32,24">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
Expand Down Expand Up @@ -46,8 +47,34 @@
</DockPanel>
</Border>

<!-- Elevation banner: not elevated -->
<Border Grid.Row="2" Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="14,12" Margin="0,0,0,12"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<DockPanel>
<Button Content="Run as administrator" Command="{Binding RelaunchElevatedCommand}"
Style="{StaticResource PrimaryButton}" DockPanel.Dock="Right" Padding="14,8"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="&#xE83D;" FontFamily="Segoe Fluent Icons,Segoe MDL2 Assets"
FontSize="16" Margin="0,0,10,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Starting and stopping Windows services requires administrator privileges."
Foreground="{StaticResource TextSecondary}" FontSize="13" VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Border>

<!-- Elevation banner: elevated -->
<Border Grid.Row="2" Background="#0D1F12" BorderBrush="#22C55E44" BorderThickness="1"
CornerRadius="8" Padding="10,8" Margin="0,0,0,12"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}}">
<StackPanel Orientation="Horizontal">
<Ellipse Width="8" Height="8" Fill="#22C55E" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="Running as administrator — you can start, stop, and configure services." Foreground="#22C55E" FontSize="13" FontWeight="Medium"/>
</StackPanel>
</Border>

<!-- Services list -->
<DataGrid AutomationProperties.Name="Data table" Grid.Row="2" ItemsSource="{Binding Services}"
<DataGrid AutomationProperties.Name="Data table" Grid.Row="3" ItemsSource="{Binding Services}"
SelectedItem="{Binding SelectedService}"
AutoGenerateColumns="False" HeadersVisibility="Column"
Background="Transparent" BorderThickness="0"
Expand Down Expand Up @@ -121,7 +148,7 @@
</DataGrid>

<!-- Status bar -->
<DockPanel Grid.Row="3" Margin="0,8,0,0">
<DockPanel Grid.Row="4" Margin="0,8,0,0">
<ProgressBar AutomationProperties.Name="Progress" DockPanel.Dock="Left" Width="120" Height="4" Margin="0,0,12,0"
IsIndeterminate="{Binding IsProgressIndeterminate}"
Visibility="{Binding IsBusy, Converter={StaticResource BoolToVis}}"/>
Expand Down
26 changes: 18 additions & 8 deletions SysManager/SysManager/Views/WindowsFeaturesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,32 @@
</WrapPanel>
</Border>

<!-- Elevation info strip (shown when not running as admin) -->
<Border Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="12,8" Margin="0,0,0,12"
Grid.Row="2" Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<!-- Elevation banner: not elevated -->
<Border Grid.Row="2" Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="14,12" Margin="0,0,0,12"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<DockPanel>
<Button Content="Run as administrator" Command="{Binding RelaunchElevatedCommand}"
Style="{StaticResource SecondaryButton}" DockPanel.Dock="Right" Padding="12,6"/>
Style="{StaticResource PrimaryButton}" DockPanel.Dock="Right" Padding="14,8"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="&#xE83D;" FontFamily="Segoe Fluent Icons,Segoe MDL2 Assets"
FontSize="14" Margin="0,0,8,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Administrator privileges required to modify Windows features."
Style="{StaticResource Subtle}" VerticalAlignment="Center"/>
FontSize="16" Margin="0,0,10,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Enabling or disabling Windows features requires administrator privileges."
Foreground="{StaticResource TextSecondary}" FontSize="13" VerticalAlignment="Center"/>
</StackPanel>
</DockPanel>
</Border>

<!-- Elevation banner: elevated -->
<Border Grid.Row="2" Background="#0D1F12" BorderBrush="#22C55E44" BorderThickness="1"
CornerRadius="8" Padding="10,8" Margin="0,0,0,12"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}}">
<StackPanel Orientation="Horizontal">
<Ellipse Width="8" Height="8" Fill="#22C55E" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="Running as administrator — you can enable and disable Windows features." Foreground="#22C55E" FontSize="13" FontWeight="Medium"/>
</StackPanel>
</Border>

<!-- Summary -->
<Border Grid.Row="3" Style="{StaticResource Card}" Margin="0,0,0,12" Padding="12">
<TextBlock Text="{Binding Summary}" FontWeight="SemiBold" FontSize="13"/>
Expand Down
44 changes: 22 additions & 22 deletions SysManager/SysManager/Views/WindowsUpdateView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@
Style="{StaticResource Subtle}" Margin="0,4,0,0"/>
</StackPanel>

<!-- Admin banner -->
<Border Grid.Row="1" Margin="28,16,28,0" Padding="16,14" CornerRadius="10"
Background="#2A1E14" BorderBrush="#F59E0B" BorderThickness="1"
<!-- Elevation banner: not elevated -->
<Border Grid.Row="1" Background="{StaticResource Surface2}" BorderBrush="{StaticResource Border1}"
BorderThickness="1" CornerRadius="8" Padding="14,12" Margin="28,12,28,0"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}, ConverterParameter=Inverse}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="&#xE7EF;" FontFamily="Segoe Fluent Icons,Segoe MDL2 Assets"
FontSize="18" Foreground="#F59E0B" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="These actions need administrator rights"
FontSize="15" FontWeight="SemiBold" Foreground="#F59E0B" VerticalAlignment="Center"/>
</StackPanel>
<TextBlock Text="Windows Update COM APIs can't list or install updates without elevation. Click the button to restart the app as admin."
Foreground="{StaticResource TextSecondary}" Margin="28,6,0,0" TextWrapping="Wrap"/>
<DockPanel>
<Button Content="Run as administrator" Command="{Binding RelaunchAsAdminCommand}"
Style="{StaticResource PrimaryButton}" DockPanel.Dock="Right" Padding="14,8"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="&#xE83D;" FontFamily="Segoe Fluent Icons,Segoe MDL2 Assets"
FontSize="16" Margin="0,0,10,0" Foreground="{StaticResource TextSecondary}"/>
<TextBlock Text="Listing and installing Windows updates requires administrator privileges."
Foreground="{StaticResource TextSecondary}" FontSize="13" VerticalAlignment="Center"/>
</StackPanel>
<Button Grid.Column="1" Content="Run as Administrator"
Command="{Binding RelaunchAsAdminCommand}"
Style="{StaticResource PrimaryButton}"
Padding="18,10" FontSize="14" VerticalAlignment="Center" Margin="16,0,0,0"/>
</Grid>
</DockPanel>
</Border>

<!-- Elevation banner: elevated -->
<Border Grid.Row="1" Background="#0D1F12" BorderBrush="#22C55E44" BorderThickness="1"
CornerRadius="8" Padding="10,8" Margin="28,12,28,0"
Visibility="{Binding IsElevated, Converter={StaticResource FlexVis}}">
<StackPanel Orientation="Horizontal">
<Ellipse Width="8" Height="8" Fill="#22C55E" VerticalAlignment="Center" Margin="0,0,10,0"/>
<TextBlock Text="Running as administrator — you can list and install updates." Foreground="#22C55E" FontSize="13" FontWeight="Medium"/>
</StackPanel>
</Border>

<!-- Module status: missing -->
Expand Down
Loading