diff --git a/SophiApp/SophiApp/Controls/CheckBox.xaml b/SophiApp/SophiApp/Controls/CheckBox.xaml index e30c024d..a76af059 100644 --- a/SophiApp/SophiApp/Controls/CheckBox.xaml +++ b/SophiApp/SophiApp/Controls/CheckBox.xaml @@ -71,7 +71,8 @@ - + + diff --git a/SophiApp/SophiApp/Customisations/CustomisationConstants.cs b/SophiApp/SophiApp/Customisations/CustomisationConstants.cs index 1fc1d7dd..c4534b22 100644 --- a/SophiApp/SophiApp/Customisations/CustomisationConstants.cs +++ b/SophiApp/SophiApp/Customisations/CustomisationConstants.cs @@ -708,7 +708,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow) }; internal static readonly string _504_MS_STORE_RESET_EXE = $@"{Environment.GetFolderPath(Environment.SpecialFolder.System)}\WSReset.exe"; - internal static readonly IEnumerable _700_VOLUME_CACHES_NAMES = new string[] { "Delivery Optimization Files", "Device Driver Packages", "Language Pack", "Previous Installations", "Setup Log Files", "System error memory dump files", "System error minidump files", "Temporary Setup Files", "Update Cleanup", "Windows Defender", "Windows ESD installation files", "Windows Upgrade Log Files" }; + internal static readonly IEnumerable _700_VOLUME_CACHES_NAMES = new string[] { "Delivery Optimization Files", "BranchCache", "Device Driver Packages", "Language Pack", "Previous Installations", "Setup Log Files", "System error memory dump files", "System error minidump files", "Temporary Setup Files", "Update Cleanup", "Windows Defender", "Windows ESD installation files", "Windows Upgrade Log Files" }; internal static readonly string _805_EVENT_VIEWS_PATH = $@"{Environment.GetEnvironmentVariable("ProgramData")}\Microsoft\Event Viewer\Views"; internal static readonly string _811_WINDOWS_SANDBOX_EXE = $@"{Environment.GetFolderPath(Environment.SpecialFolder.System)}\WindowsSandbox.exe"; internal static readonly string _922_MS_WORDPAD_EXE = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\Windows NT\Accessories\wordpad.exe"; diff --git a/SophiApp/SophiApp/Customisations/CustomisationOs.cs b/SophiApp/SophiApp/Customisations/CustomisationOs.cs index acd9b300..74def33a 100644 --- a/SophiApp/SophiApp/Customisations/CustomisationOs.cs +++ b/SophiApp/SophiApp/Customisations/CustomisationOs.cs @@ -593,80 +593,86 @@ public static void _304(bool IsChecked) => RegHelper.SetValue(RegistryHive.Curre public static void _307(bool _) { - var localAppDataTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_LOCAL_APPDATA}\\{TEMP_FOLDER}"); - var systemDriveTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_SYSTEM_DRIVE}\\{TEMP_FOLDER}"); - var systemRootTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_SYSTEM_ROOT}\\{TEMP_FOLDER}"); - var currentTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_TEMP}"); - var userName = Environment.UserName; - - ServiceHelper.Restart(SERVICE_SPOOLER); - OneDriveHelper.StopProcesses(); - FileHelper.CreateDirectory(systemDriveTemp); - FileHelper.DirectoryLazyDelete(systemRootTemp); - - if (FileHelper.IsSymbolicLink(currentTemp).Invert()) + if (ServiceHelper.ServiceExist(SERVICE_SPOOLER)) { - FileHelper.DirectoryLazyDelete(currentTemp); - - if (FileHelper.DirectoryIsEmpty(currentTemp)) - { - FileHelper.TryDirectoryDelete(localAppDataTemp); - FileHelper.CreateDirectoryLink(localAppDataTemp, systemDriveTemp); - } - else + var localAppDataTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_LOCAL_APPDATA}\\{TEMP_FOLDER}"); + var systemDriveTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_SYSTEM_DRIVE}\\{TEMP_FOLDER}"); + var systemRootTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_SYSTEM_ROOT}\\{TEMP_FOLDER}"); + var currentTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_TEMP}"); + var userName = Environment.UserName; + + ServiceHelper.TryRestart(SERVICE_SPOOLER); + OneDriveHelper.StopProcesses(); + FileHelper.CreateDirectory(systemDriveTemp); + FileHelper.DirectoryLazyDelete(systemRootTemp); + + if (FileHelper.IsSymbolicLink(currentTemp).Invert()) { - ScheduledTaskHelper.RegisterLogonTask(name: _307_SYMBOLIC_LINK_TASK, description: null, execute: POWERSHELL_EXE, arg: _307_TASK_ARGS, username: userName); + FileHelper.DirectoryLazyDelete(currentTemp); + + if (FileHelper.DirectoryIsEmpty(currentTemp)) + { + FileHelper.TryDirectoryDelete(localAppDataTemp); + FileHelper.CreateDirectoryLink(localAppDataTemp, systemDriveTemp); + } + else + { + ScheduledTaskHelper.RegisterLogonTask(name: _307_SYMBOLIC_LINK_TASK, description: null, execute: POWERSHELL_EXE, arg: _307_TASK_ARGS, username: userName); + } } - } - Environment.SetEnvironmentVariable(TMP, systemDriveTemp, EnvironmentVariableTarget.User); - Environment.SetEnvironmentVariable(TMP, systemDriveTemp, EnvironmentVariableTarget.Machine); - Environment.SetEnvironmentVariable(TMP, systemDriveTemp, EnvironmentVariableTarget.Process); - RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TMP, _307_SYSTEM_DRIVE_TEMP, RegistryValueKind.ExpandString); - Environment.SetEnvironmentVariable(TEMP, systemDriveTemp, EnvironmentVariableTarget.User); - Environment.SetEnvironmentVariable(TEMP, systemDriveTemp, EnvironmentVariableTarget.Machine); - Environment.SetEnvironmentVariable(TEMP, systemDriveTemp, EnvironmentVariableTarget.Process); - RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TEMP, _307_SYSTEM_DRIVE_TEMP, RegistryValueKind.ExpandString); - RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TMP, systemDriveTemp, RegistryValueKind.ExpandString); - RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TEMP, systemDriveTemp, RegistryValueKind.ExpandString); + Environment.SetEnvironmentVariable(TMP, systemDriveTemp, EnvironmentVariableTarget.User); + Environment.SetEnvironmentVariable(TMP, systemDriveTemp, EnvironmentVariableTarget.Machine); + Environment.SetEnvironmentVariable(TMP, systemDriveTemp, EnvironmentVariableTarget.Process); + RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TMP, _307_SYSTEM_DRIVE_TEMP, RegistryValueKind.ExpandString); + Environment.SetEnvironmentVariable(TEMP, systemDriveTemp, EnvironmentVariableTarget.User); + Environment.SetEnvironmentVariable(TEMP, systemDriveTemp, EnvironmentVariableTarget.Machine); + Environment.SetEnvironmentVariable(TEMP, systemDriveTemp, EnvironmentVariableTarget.Process); + RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TEMP, _307_SYSTEM_DRIVE_TEMP, RegistryValueKind.ExpandString); + RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TMP, systemDriveTemp, RegistryValueKind.ExpandString); + RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TEMP, systemDriveTemp, RegistryValueKind.ExpandString); + } } public static void _308(bool _) { - var localAppDataTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_LOCAL_APPDATA}\\{TEMP_FOLDER}"); - var systemRootTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_SYSTEM_ROOT}\\{TEMP_FOLDER}"); - var currentTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_TEMP}"); - var userName = Environment.UserName; - - ServiceHelper.Restart(SERVICE_SPOOLER); - OneDriveHelper.StopProcesses(); - FileHelper.DirectoryLazyDelete(localAppDataTemp); - FileHelper.CreateDirectory(systemRootTemp, localAppDataTemp); - - if (FileHelper.IsSymbolicLink(currentTemp).Invert()) + if (ServiceHelper.ServiceExist(SERVICE_SPOOLER)) { - FileHelper.DirectoryLazyDelete(currentTemp); + var localAppDataTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_LOCAL_APPDATA}\\{TEMP_FOLDER}"); + var systemRootTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_SYSTEM_ROOT}\\{TEMP_FOLDER}"); + var currentTemp = Environment.ExpandEnvironmentVariables($"{ENVIRONMENT_TEMP}"); + var userName = Environment.UserName; - if (Directory.Exists(currentTemp) && FileHelper.DirectoryIsEmpty(currentTemp)) - { - FileHelper.TryDirectoryDelete(currentTemp); - } - else + ServiceHelper.TryRestart(SERVICE_SPOOLER); + OneDriveHelper.StopProcesses(); + FileHelper.DirectoryLazyDelete(localAppDataTemp); + FileHelper.CreateDirectory(systemRootTemp, localAppDataTemp); + + if (FileHelper.IsSymbolicLink(currentTemp).Invert()) { - ScheduledTaskHelper.RegisterLogonTask(name: _308_TEMPORARY_TASK, description: null, execute: POWERSHELL_EXE, arg: _308_TASK_ARGS, username: userName); + FileHelper.DirectoryLazyDelete(currentTemp); + + if (Directory.Exists(currentTemp) && FileHelper.DirectoryIsEmpty(currentTemp)) + { + FileHelper.TryDirectoryDelete(currentTemp); + } + else + { + ScheduledTaskHelper.RegisterLogonTask(name: _308_TEMPORARY_TASK, description: null, execute: POWERSHELL_EXE, arg: _308_TASK_ARGS, username: userName); + } } - } - Environment.SetEnvironmentVariable(TMP, localAppDataTemp, EnvironmentVariableTarget.User); - Environment.SetEnvironmentVariable(TMP, systemRootTemp, EnvironmentVariableTarget.Machine); - Environment.SetEnvironmentVariable(TMP, localAppDataTemp, EnvironmentVariableTarget.Process); - RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TMP, _308_APPDATA_TEMP, RegistryValueKind.ExpandString); - Environment.SetEnvironmentVariable(TEMP, localAppDataTemp, EnvironmentVariableTarget.User); - Environment.SetEnvironmentVariable(TEMP, systemRootTemp, EnvironmentVariableTarget.Machine); - Environment.SetEnvironmentVariable(TEMP, localAppDataTemp, EnvironmentVariableTarget.Process); - RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TEMP, _308_APPDATA_TEMP, RegistryValueKind.ExpandString); - RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TMP, systemRootTemp, RegistryValueKind.ExpandString); - RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TEMP, systemRootTemp, RegistryValueKind.ExpandString); + Environment.SetEnvironmentVariable(TMP, localAppDataTemp, EnvironmentVariableTarget.User); + Environment.SetEnvironmentVariable(TMP, systemRootTemp, EnvironmentVariableTarget.Machine); + Environment.SetEnvironmentVariable(TMP, localAppDataTemp, EnvironmentVariableTarget.Process); + RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TMP, _308_APPDATA_TEMP, RegistryValueKind.ExpandString); + Environment.SetEnvironmentVariable(TEMP, localAppDataTemp, EnvironmentVariableTarget.User); + Environment.SetEnvironmentVariable(TEMP, systemRootTemp, EnvironmentVariableTarget.Machine); + Environment.SetEnvironmentVariable(TEMP, localAppDataTemp, EnvironmentVariableTarget.Process); + RegHelper.SetValue(RegistryHive.CurrentUser, ENVIRONMENT, TEMP, _308_APPDATA_TEMP, RegistryValueKind.ExpandString); + RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TMP, systemRootTemp, RegistryValueKind.ExpandString); + RegHelper.SetValue(RegistryHive.LocalMachine, SESSION_MANAGER_ENVIRONMENT, TEMP, systemRootTemp, RegistryValueKind.ExpandString); + } } public static void _309(bool IsChecked) => RegHelper.SetValue(RegistryHive.LocalMachine, diff --git a/SophiApp/SophiApp/Customisations/CustomisationStatus.cs b/SophiApp/SophiApp/Customisations/CustomisationStatus.cs index 57c1c3e5..5e0cebb1 100644 --- a/SophiApp/SophiApp/Customisations/CustomisationStatus.cs +++ b/SophiApp/SophiApp/Customisations/CustomisationStatus.cs @@ -478,9 +478,11 @@ public static bool _358() => DotNetHelper.IsInstalled("windowsdesktop-runtime-6. : throw new FileNotExistException("windowsdesktop-runtime-6.*-win-x64.exe"); public static bool _500() => HttpHelper.IsOnline - ? UwpHelper.PackageExist(UWP_MS_WIN_PHOTOS) - ? UwpHelper.PackageExist(_500_UWP_HEVC_VIDEO) - : throw new UwpAppFoundException(UWP_MS_WIN_PHOTOS) + ? OsHelper.GetBuild() < 22517 + ? UwpHelper.PackageExist(UWP_MS_WIN_PHOTOS) + ? UwpHelper.PackageExist(_500_UWP_HEVC_VIDEO) + : throw new UwpAppFoundException(UWP_MS_WIN_PHOTOS) + : throw new WindowsBuildNotSupportedException() : throw new NoInternetConnectionException(); public static bool _501() => UwpHelper.PackageExist(UWP_MS_CORTANA) diff --git a/SophiApp/SophiApp/Helpers/ExceptionsHelper.cs b/SophiApp/SophiApp/Helpers/ExceptionsHelper.cs index 7804909a..f09e24ca 100644 --- a/SophiApp/SophiApp/Helpers/ExceptionsHelper.cs +++ b/SophiApp/SophiApp/Helpers/ExceptionsHelper.cs @@ -177,6 +177,13 @@ public WddmMinimalVersionException(string minimumVersion, string currentVersion) } } + internal class WindowsBuildNotSupportedException : Exception + { + public WindowsBuildNotSupportedException() : base("This OS build is not supported") + { + } + } + internal class WindowsCapabilityNotInstalledException : Exception { public WindowsCapabilityNotInstalledException(string name) : base($"The Windows capability {name} wasn't installed in this OS") diff --git a/SophiApp/SophiApp/Helpers/ServiceHelper.cs b/SophiApp/SophiApp/Helpers/ServiceHelper.cs index c24879c4..ff9ab3cc 100644 --- a/SophiApp/SophiApp/Helpers/ServiceHelper.cs +++ b/SophiApp/SophiApp/Helpers/ServiceHelper.cs @@ -53,6 +53,21 @@ internal static void Restart(string serviceName) internal static bool ServiceExist(string serviceName) => ServiceController.GetServices().Any(service => service.ServiceName == serviceName); + internal static void TryRestart(string serviceName) + { + try + { + var service = Get(serviceName); + if (service.StartType != ServiceStartMode.Disabled) + { + Restart(serviceName); + } + } + catch (Exception) + { + } + } + public static void SetStartMode(ServiceController svc, ServiceStartMode mode) { var scManagerHandle = OpenSCManager(null, null, SC_MANAGER_ALL_ACCESS); diff --git a/SophiApp/SophiApp/Localizations/IT.xaml b/SophiApp/SophiApp/Localizations/IT.xaml index 90306987..37947f08 100644 --- a/SophiApp/SophiApp/Localizations/IT.xaml +++ b/SophiApp/SophiApp/Localizations/IT.xaml @@ -96,4 +96,4 @@ riavvia il computer dopo aver Applicato le impostazioni Leggendo le impostazioni correnti... Apri in Windows Terminal - + \ No newline at end of file diff --git a/SophiApp/SophiApp/Localizations/TR.xaml b/SophiApp/SophiApp/Localizations/TR.xaml index 42004963..8e520114 100644 --- a/SophiApp/SophiApp/Localizations/TR.xaml +++ b/SophiApp/SophiApp/Localizations/TR.xaml @@ -56,7 +56,7 @@ Çalıştır [Helen] Windows® - ile hazırlandı. + ile hazırlandı. GitHub Tema Karanlık @@ -96,4 +96,4 @@ Ayarları uyguladıktan sonra lütfen bilgisayarınızı yeniden başlatın Geçerli ayarlar okunuyor... Windows Terminalinde Aç - + \ No newline at end of file