mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-30 17:07:23 +01:00
Compare commits
2 Commits
stable
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7bdb5d8d3 | ||
|
|
516e9878a9 |
@@ -201,6 +201,13 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
|
||||
if (action == UPDATE_NOW_LAUNCH_STAGE1)
|
||||
{
|
||||
// Check if user has admin permissions before proceeding
|
||||
if (!check_user_is_admin())
|
||||
{
|
||||
Logger::error("Update failed: Administrator permissions required to install updates");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool isUpToDate = false;
|
||||
auto installerPath = ObtainInstaller(isUpToDate);
|
||||
bool failed = !installerPath.has_value();
|
||||
@@ -217,6 +224,12 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
}
|
||||
else if (action == UPDATE_NOW_LAUNCH_STAGE2)
|
||||
{
|
||||
// Check if user has admin permissions before proceeding
|
||||
if (!check_user_is_admin())
|
||||
{
|
||||
Logger::error("Update failed: Administrator permissions required to install updates");
|
||||
return 1;
|
||||
}
|
||||
using namespace std::string_view_literals;
|
||||
const bool failed = !InstallNewVersionStage2(args[2]);
|
||||
if (failed)
|
||||
|
||||
@@ -102,6 +102,14 @@
|
||||
IsTabStop="{x:Bind ViewModel.IsNoNetwork, Mode=OneWay}"
|
||||
Severity="Error" />
|
||||
|
||||
<!-- Insufficient permissions error -->
|
||||
<InfoBar
|
||||
x:Uid="General_InsufficientPermissions"
|
||||
IsClosable="False"
|
||||
IsOpen="{x:Bind ViewModel.IsInsufficientPermissions, Mode=OneWay}"
|
||||
IsTabStop="{x:Bind ViewModel.IsInsufficientPermissions, Mode=OneWay}"
|
||||
Severity="Error" />
|
||||
|
||||
<!-- New version available -->
|
||||
<InfoBar
|
||||
x:Uid="General_NewVersionAvailable"
|
||||
|
||||
@@ -2414,6 +2414,9 @@ From there, simply click on one of the supported files in the File Explorer and
|
||||
<data name="General_CantCheck.Title" xml:space="preserve">
|
||||
<value>Network error. Please try again later</value>
|
||||
</data>
|
||||
<data name="General_InsufficientPermissions.Title" xml:space="preserve">
|
||||
<value>Administrator permissions required. Please restart PowerToys as administrator to install updates.</value>
|
||||
</data>
|
||||
<data name="General_DownloadAndInstall.Content" xml:space="preserve">
|
||||
<value>Download & install</value>
|
||||
</data>
|
||||
|
||||
@@ -260,6 +260,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
private bool _isNewVersionDownloading;
|
||||
private bool _isNewVersionChecked;
|
||||
private bool _isNoNetwork;
|
||||
private bool _isInsufficientPermissions;
|
||||
private bool _isBugReportRunning;
|
||||
|
||||
private bool _settingsBackupRestoreMessageVisible;
|
||||
@@ -953,6 +954,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInsufficientPermissions
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isInsufficientPermissions;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBugReportRunning
|
||||
{
|
||||
get
|
||||
@@ -1178,6 +1187,18 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
private void UpdateNowClick()
|
||||
{
|
||||
// Check if user has admin permissions before starting update
|
||||
if (!IsAdmin)
|
||||
{
|
||||
_isInsufficientPermissions = true;
|
||||
NotifyPropertyChanged(nameof(IsInsufficientPermissions));
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear any previous permission error
|
||||
_isInsufficientPermissions = false;
|
||||
NotifyPropertyChanged(nameof(IsInsufficientPermissions));
|
||||
|
||||
IsNewVersionDownloading = string.IsNullOrEmpty(UpdatingSettingsConfig.DownloadedInstallerFilename);
|
||||
NotifyPropertyChanged(nameof(IsDownloadAllowed));
|
||||
|
||||
@@ -1299,6 +1320,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
|
||||
_isNoNetwork = PowerToysUpdatingState == UpdatingSettings.UpdatingState.NetworkError;
|
||||
NotifyPropertyChanged(nameof(IsNoNetwork));
|
||||
|
||||
// Clear permission error when updating state changes
|
||||
_isInsufficientPermissions = false;
|
||||
NotifyPropertyChanged(nameof(IsInsufficientPermissions));
|
||||
|
||||
NotifyPropertyChanged(nameof(IsNewVersionDownloading));
|
||||
NotifyPropertyChanged(nameof(IsUpdatePanelVisible));
|
||||
_isNewVersionChecked = PowerToysUpdatingState == UpdatingSettings.UpdatingState.UpToDate && !IsNewVersionDownloading;
|
||||
|
||||
Reference in New Issue
Block a user