From 2ec0a13c1f0fce78bd039f1d5837be48dcc29f34 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sat, 8 Jul 2023 22:49:43 +0300 Subject: [PATCH] Code refactoring --- Wrapper/Config/config_Windows_10.json | 2 +- Wrapper/Config/config_Windows_10_LTSC.json | 2 +- Wrapper/Config/config_Windows_11.json | 2 +- Wrapper/Localizations/de-DE/tag.json | 2 +- .../de-DE/tooltip_Windows_10.json | 2 +- .../de-DE/tooltip_Windows_11.json | 2 +- .../en-US/tooltip_Windows_10.json | 6 +- .../en-US/tooltip_Windows_11.json | 6 +- Wrapper/Localizations/ru-RU/tag.json | 2 +- .../ru-RU/tooltip_Windows_10.json | 2 +- .../ru-RU/tooltip_Windows_11.json | 2 +- .../Functions.ps1 | 2 +- .../Localizations/de-DE/Sophia.psd1 | 3 +- .../Localizations/en-US/Sophia.psd1 | 3 +- .../Localizations/es-ES/Sophia.psd1 | 3 +- .../Localizations/fr-FR/Sophia.psd1 | 3 +- .../Localizations/hu-HU/Sophia.psd1 | 3 +- .../Localizations/it-IT/Sophia.psd1 | 3 +- .../Localizations/pl-PL/Sophia.psd1 | 3 +- .../Localizations/pt-BR/Sophia.psd1 | 3 +- .../Localizations/ru-RU/Sophia.psd1 | 3 +- .../Localizations/tr-TR/Sophia.psd1 | 3 +- .../Localizations/uk-UA/Sophia.psd1 | 3 +- .../Localizations/zh-CN/Sophia.psd1 | 3 +- .../Module/Sophia.psm1 | 1080 ++++++++-------- src/Sophia_Script_for_Windows_10/Sophia.ps1 | 4 +- .../Functions.ps1 | 2 +- .../Localizations/de-DE/Sophia.psd1 | 3 +- .../Localizations/en-US/Sophia.psd1 | 3 +- .../Localizations/es-ES/Sophia.psd1 | 5 +- .../Localizations/fr-FR/Sophia.psd1 | 3 +- .../Localizations/hu-HU/Sophia.psd1 | 3 +- .../Localizations/it-IT/Sophia.psd1 | 3 +- .../Localizations/pl-PL/Sophia.psd1 | 3 +- .../Localizations/pt-BR/Sophia.psd1 | 3 +- .../Localizations/ru-RU/Sophia.psd1 | 3 +- .../Localizations/tr-TR/Sophia.psd1 | 3 +- .../Localizations/uk-UA/Sophia.psd1 | 3 +- .../Localizations/zh-CN/Sophia.psd1 | 3 +- .../Module/Sophia.psm1 | 1080 ++++++++-------- .../Sophia.ps1 | 4 +- .../Functions.ps1 | 2 +- .../Localizations/de-DE/Sophia.psd1 | 5 +- .../Localizations/en-US/Sophia.psd1 | 5 +- .../Localizations/es-ES/Sophia.psd1 | 5 +- .../Localizations/fr-FR/Sophia.psd1 | 5 +- .../Localizations/hu-HU/Sophia.psd1 | 5 +- .../Localizations/it-IT/Sophia.psd1 | 5 +- .../Localizations/pl-PL/Sophia.psd1 | 5 +- .../Localizations/pt-BR/Sophia.psd1 | 5 +- .../Localizations/ru-RU/Sophia.psd1 | 5 +- .../Localizations/tr-TR/Sophia.psd1 | 5 +- .../Localizations/uk-UA/Sophia.psd1 | 5 +- .../Localizations/zh-CN/Sophia.psd1 | 5 +- .../Module/Sophia.psm1 | 1086 ++++++++--------- .../Sophia.ps1 | 6 +- .../Functions.ps1 | 2 +- .../Localizations/de-DE/Sophia.psd1 | 3 +- .../Localizations/en-US/Sophia.psd1 | 3 +- .../Localizations/es-ES/Sophia.psd1 | 3 +- .../Localizations/fr-FR/Sophia.psd1 | 3 +- .../Localizations/hu-HU/Sophia.psd1 | 3 +- .../Localizations/it-IT/Sophia.psd1 | 3 +- .../Localizations/pl-PL/Sophia.psd1 | 3 +- .../Localizations/pt-BR/Sophia.psd1 | 3 +- .../Localizations/ru-RU/Sophia.psd1 | 3 +- .../Localizations/tr-TR/Sophia.psd1 | 3 +- .../Localizations/uk-UA/Sophia.psd1 | 3 +- .../Localizations/zh-CN/Sophia.psd1 | 3 +- .../Module/Sophia.psm1 | 1080 ++++++++-------- .../Sophia.ps1 | 4 +- .../Functions.ps1 | 2 +- .../Localizations/de-DE/Sophia.psd1 | 3 +- .../Localizations/en-US/Sophia.psd1 | 3 +- .../Localizations/es-ES/Sophia.psd1 | 3 +- .../Localizations/fr-FR/Sophia.psd1 | 3 +- .../Localizations/hu-HU/Sophia.psd1 | 3 +- .../Localizations/it-IT/Sophia.psd1 | 3 +- .../Localizations/pl-PL/Sophia.psd1 | 3 +- .../Localizations/pt-BR/Sophia.psd1 | 3 +- .../Localizations/ru-RU/Sophia.psd1 | 3 +- .../Localizations/tr-TR/Sophia.psd1 | 3 +- .../Localizations/uk-UA/Sophia.psd1 | 3 +- .../Localizations/zh-CN/Sophia.psd1 | 3 +- .../Module/Sophia.psm1 | 1080 ++++++++-------- src/Sophia_Script_for_Windows_11/Sophia.ps1 | 4 +- .../Functions.ps1 | 2 +- .../Localizations/de-DE/Sophia.psd1 | 3 +- .../Localizations/en-US/Sophia.psd1 | 3 +- .../Localizations/es-ES/Sophia.psd1 | 3 +- .../Localizations/fr-FR/Sophia.psd1 | 3 +- .../Localizations/hu-HU/Sophia.psd1 | 3 +- .../Localizations/it-IT/Sophia.psd1 | 3 +- .../Localizations/pl-PL/Sophia.psd1 | 3 +- .../Localizations/pt-BR/Sophia.psd1 | 3 +- .../Localizations/ru-RU/Sophia.psd1 | 3 +- .../Localizations/tr-TR/Sophia.psd1 | 3 +- .../Localizations/uk-UA/Sophia.psd1 | 3 +- .../Localizations/zh-CN/Sophia.psd1 | 3 +- .../Module/Sophia.psm1 | 1081 ++++++++-------- .../Sophia.ps1 | 4 +- 101 files changed, 3313 insertions(+), 3484 deletions(-) diff --git a/Wrapper/Config/config_Windows_10.json b/Wrapper/Config/config_Windows_10.json index be5c7ecec..fba4a2a47 100644 --- a/Wrapper/Config/config_Windows_10.json +++ b/Wrapper/Config/config_Windows_10.json @@ -4,7 +4,7 @@ "Region": "Protection", "Control": "cmb", "Required": "true", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning" diff --git a/Wrapper/Config/config_Windows_10_LTSC.json b/Wrapper/Config/config_Windows_10_LTSC.json index 275f6569e..3daca208d 100644 --- a/Wrapper/Config/config_Windows_10_LTSC.json +++ b/Wrapper/Config/config_Windows_10_LTSC.json @@ -4,7 +4,7 @@ "Region": "Protection", "Control": "cmb", "Required": "true", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning" diff --git a/Wrapper/Config/config_Windows_11.json b/Wrapper/Config/config_Windows_11.json index 9d0506dc3..02e1c7c29 100644 --- a/Wrapper/Config/config_Windows_11.json +++ b/Wrapper/Config/config_Windows_11.json @@ -4,7 +4,7 @@ "Region": "Protection", "Control": "cmb", "Required": "true", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning" diff --git a/Wrapper/Localizations/de-DE/tag.json b/Wrapper/Localizations/de-DE/tag.json index 1a4522b5d..7870dfef9 100644 --- a/Wrapper/Localizations/de-DE/tag.json +++ b/Wrapper/Localizations/de-DE/tag.json @@ -1,6 +1,6 @@ { "Warning": "Warnen", - "Checks": "Überprüfen", + "InitialActions": "Überprüfen", "Disable": "Deaktivieren", "Enable": "Aktivieren", "None": "Nichts", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json index a5616d38f..e6d162003 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json +++ b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json @@ -2,7 +2,7 @@ { "Id": 100, "Region": "Protection", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json index 21ae11377..09370191f 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json +++ b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json @@ -2,7 +2,7 @@ { "Id": 100, "Region": "Protection", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning", diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_10.json b/Wrapper/Localizations/en-US/tooltip_Windows_10.json index e5dc5d3d8..0935a2471 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_10.json +++ b/Wrapper/Localizations/en-US/tooltip_Windows_10.json @@ -2,15 +2,15 @@ { "Id": 100, "Region": "Protection", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning", - "ToolTip": "The mandatory Checks. If you want to disable a warning message about whether the preset file was customized, remove the \"-Warning\" argument." + "ToolTip": "The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the \"-Warning\" argument." }, "One": { "Tag": "", - "ToolTip": "The mandatory Checks. No argument therefore no warning message about whether you've customized the preset file." + "ToolTip": "The mandatory checks. No argument therefore no warning message about whether you've customized the preset file." } } }, diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_11.json b/Wrapper/Localizations/en-US/tooltip_Windows_11.json index 5cba95900..a00df766b 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_11.json +++ b/Wrapper/Localizations/en-US/tooltip_Windows_11.json @@ -2,15 +2,15 @@ { "Id": 100, "Region": "Protection", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning", - "ToolTip": "The mandatory Checks. If you want to disable a warning message about whether the preset file was customized, remove the \"-Warning\" argument." + "ToolTip": "The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the \"-Warning\" argument." }, "One": { "Tag": "", - "ToolTip": "The mandatory Checks. No argument therefore no warning message about whether you've customized the preset file." + "ToolTip": "The mandatory checks. No argument therefore no warning message about whether you've customized the preset file." } } }, diff --git a/Wrapper/Localizations/ru-RU/tag.json b/Wrapper/Localizations/ru-RU/tag.json index a15295c64..dbb6f11b6 100644 --- a/Wrapper/Localizations/ru-RU/tag.json +++ b/Wrapper/Localizations/ru-RU/tag.json @@ -1,6 +1,6 @@ { "Warning": "Предупреждение", - "Checks": "Проверки", + "InitialActions": "Проверки", "Disable": "Выключить", "Enable": "Включить", "None": "Пропустить", diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json index a934208e2..3ff4eba64 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json +++ b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json @@ -2,7 +2,7 @@ { "Id": 100, "Region": "Protection", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning", diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json index 2375b0572..1dfc5fd57 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json +++ b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json @@ -2,7 +2,7 @@ { "Id": 100, "Region": "Protection", - "Function": "Checks", + "Function": "InitialActions", "Arg": { "Zero": { "Tag": "Warning", diff --git a/src/Sophia_Script_for_Windows_10/Functions.ps1 b/src/Sophia_Script_for_Windows_10/Functions.ps1 index 2e0a9db3b..dca2e4b80 100644 --- a/src/Sophia_Script_for_Windows_10/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10/Functions.ps1 @@ -58,7 +58,7 @@ Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia -BaseDirectory $PSScriptRoot\Localizations # The mandatory checks. Please, do not comment out this function -Checks +InitialActions $Parameters = @{ CommandName = "Sophia" diff --git a/src/Sophia_Script_for_Windows_10/Localizations/de-DE/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/de-DE/Sophia.psd1 index 471e6817a..837a5aeef 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/de-DE/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/de-DE/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Die Verknüpfung "{0}" wird an Start UninstallUWPForAll = Für alle Benutzer UWPAppsTitle = UWP-Apps HEVCDownloading = HEVC-Videoerweiterungen vom Gerätehersteller herunterladen... -GraphicsPerformanceTitle = Bevorzugte Grafikleistung -GraphicsPerformanceRequest = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? +GraphicsPerformanceTitle = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Der Zugriff auf Windows Script Host wurde für diesem Computer deaktiviert. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = Die Funktion "{0}" wurde bereits als "{1}" angelegt. diff --git a/src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1 index 164458d41..e9358bf42 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = The "{0}" shortcut is being pinned t UninstallUWPForAll = For all users UWPAppsTitle = UWP Apps HEVCDownloading = Downloading HEVC Video Extensions from Device Manufacturer... -GraphicsPerformanceTitle = Graphics performance preference -GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +GraphicsPerformanceTitle = Would you like to set the graphics performance setting of an app of your choice to "High performance"? ActionCenter = In order to use "{0}" function you have to enable Action Center. WindowsScriptHost = Windows Script Host access is disabled on this machine. In order to use "{0}" function you have to enable Windows Script Host. ScheduledTaskPresented = The "{0}" function was already created as "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/es-ES/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/es-ES/Sophia.psd1 index e3c65b048..df1ced82d 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/es-ES/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/es-ES/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = El acceso directo "{0}" está siendo UninstallUWPForAll = Para todos los usuarios UWPAppsTitle = Aplicaciones UWP HEVCDownloading = Descargando HEVC Vídeo Extensiones del Fabricante del dispositivo... -GraphicsPerformanceTitle = Preferencia de rendimiento gráfico -GraphicsPerformanceRequest = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? +GraphicsPerformanceTitle = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Acceso a Windows Script Host deshabilitado en este equipo. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = La función "{0}" ya fue creada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/fr-FR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/fr-FR/Sophia.psd1 index f134fa706..f2f50283b 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/fr-FR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/fr-FR/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Le raccourci "{0}" est épinglé sur UninstallUWPForAll = Pour tous les utilisateurs UWPAppsTitle = Applications UWP HEVCDownloading = Téléchargement de Extensions vidéo HEVC du fabricant de l'appareil... -GraphicsPerformanceTitle = Préférence de performances graphiques -GraphicsPerformanceRequest = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? +GraphicsPerformanceTitle = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? ActionCenter = Pour utiliser la fonction "{0}", vous devez activer le Centre d'action. WindowsScriptHost = L'accès à Windows Script Host est désactivé sur cette machine. Pour utiliser la fonction "{0}", vous devez activer Windows Script Host. ScheduledTaskPresented = La fonction "{0}" a déjà été créée en tant que "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/hu-HU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/hu-HU/Sophia.psd1 index 731212a18..f3ebe673b 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/hu-HU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/hu-HU/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = A gyorsindító ikon "{0}" Startmen UninstallUWPForAll = Az összes felhasználó számára UWPAppsTitle = UWP Alkalmazások HEVCDownloading = A HEVC Videobővítmények letöltése a gyártói oldalról... -GraphicsPerformanceTitle = Grafikus teljesítmény tulajdonság -GraphicsPerformanceRequest = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? +GraphicsPerformanceTitle = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? ActionCenter = Az "{0}" funkció használatához engedélyeznie kell az Action Center funkciót. WindowsScriptHost = A Windows Script Host ezen a gépen nem érhető el. Az "{0}" funkció használatához engedélyeznie kell a Windows Script Host. ScheduledTaskPresented = A "{0}" funkciót már létrehoztuk "{1}" néven. diff --git a/src/Sophia_Script_for_Windows_10/Localizations/it-IT/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/it-IT/Sophia.psd1 index 86efd6207..116d8e8a1 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/it-IT/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/it-IT/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Il collegamento "{0}" è stato blocc UninstallUWPForAll = Per tutti gli utenti UWPAppsTitle = UWP Apps HEVCDownloading = Download del codec video HEVC Video estenxion dal produttore... -GraphicsPerformanceTitle = Preferenza per le prestazioni grafiche -GraphicsPerformanceRequest = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? +GraphicsPerformanceTitle = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? ActionCenter = Per utilizzare la funzione "{0}" è necessario attivare il Centro operativo. WindowsScriptHost = Accesso a Windows Script Host disabilitato sul computer in uso. Per utilizzare la funzione "{0}" è necessario abilitare Windows Script Host. ScheduledTaskPresented = La funzione "{0}" è già stata creata come "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/pl-PL/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/pl-PL/Sophia.psd1 index 02bb7efaf..774a36eab 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/pl-PL/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/pl-PL/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Skrót "{0}" jest przypinany do Star UninstallUWPForAll = Dla wszystkich użytkowników UWPAppsTitle = Aplikacje UWP HEVCDownloading = Pobieranie rozszerzeń wideo HEVC od producenta urządzenia... -GraphicsPerformanceTitle = Preferencje dotyczące wydajności grafiki -GraphicsPerformanceRequest = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? +GraphicsPerformanceTitle = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? ActionCenter = Aby korzystać z funkcji "{0}" należy włączyć Action Center. WindowsScriptHost = Dostęp do Hosta skryptów systemu Windows jest wyłączony na tym komputerze. Aby korzystać z funkcji "{0}" należy włączyć Windows Script Host. ScheduledTaskPresented = Funkcja "{0}" została już utworzona jako "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/pt-BR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/pt-BR/Sophia.psd1 index ab8d24f0d..b70b4353b 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/pt-BR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/pt-BR/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = O atalho "{0}" está sendo fixado no UninstallUWPForAll = Para todos os usuários... UWPAppsTitle = Apps UWP HEVCDownloading = Baixando HEVC Vídeo Extensões de Dispositivo Fabricante... -GraphicsPerformanceTitle = Preferência de desempenho gráfico -GraphicsPerformanceRequest = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? +GraphicsPerformanceTitle = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? ActionCenter = Para utilizar a função {0}", tem de activar o Centro de Acção. WindowsScriptHost = O acesso ao Windows Script Host está desactivado neste computador. Para usar a função "{0}", é necessário ativar o Windows Script Host. ScheduledTaskPresented = A função "{0}" já foi criada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/ru-RU/Sophia.psd1 index 0c1c191fb..7c1d0f98b 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/ru-RU/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Ярлык "{0}" закрепляе UninstallUWPForAll = Для всех пользователей UWPAppsTitle = UWP-приложения HEVCDownloading = Скачивается расширение "Расширения для видео HEVC от производителя устройства"... -GraphicsPerformanceTitle = Настройка производительности графики -GraphicsPerformanceRequest = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? +GraphicsPerformanceTitle = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? ActionCenter = Чтобы использовать функцию "{0}" вам необходимо включить центр уведомлений. WindowsScriptHost = На данном компьютере отключен доступ к серверу сценариев Windows. Чтобы использовать функцию "{0}", вам необходимо включить сервер сценариев Windows. ScheduledTaskPresented = Функция "{0}" уже была создана от имени "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/tr-TR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/tr-TR/Sophia.psd1 index 04fe033e6..d7c5774ea 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/tr-TR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/tr-TR/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = "{0}" kısayolu Başlangıç sekmesi UninstallUWPForAll = Bütün kullanıcılar için UWPAppsTitle = UWP Uygulamaları HEVCDownloading = "Cihaz Üreticisinden HEVC Video Uzantıları" İndiriliyor... -GraphicsPerformanceTitle = Grafik performans tercihi -GraphicsPerformanceRequest = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? +GraphicsPerformanceTitle = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? ActionCenter = "{0}" işlevini kullanmak için Eylem Merkezi'ni etkinleştirmeniz gerekir. WindowsScriptHost = Windows Kod Merkezi erişimi bu makineden devre dışı. "{0}" işlevini kullanmak için Windows Kod Merkezi'u etkinleştirmeniz gerekir. ScheduledTaskPresented = "{0}" işlevi zaten "{1}" olarak oluşturulmuştu. diff --git a/src/Sophia_Script_for_Windows_10/Localizations/uk-UA/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/uk-UA/Sophia.psd1 index f489e002d..4bf816e7f 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/uk-UA/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/uk-UA/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Ярлик "{0}" закріплює UninstallUWPForAll = Для всіх користувачів UWPAppsTitle = UWP-додатки HEVCDownloading = Завантажується розширення "Розширення для відео HEVC від виробника пристрою"... -GraphicsPerformanceTitle = Налаштування продуктивності графіки -GraphicsPerformanceRequest = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? +GraphicsPerformanceTitle = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? ActionCenter = Щоб використовувати функцію "{0}" вам необхідно увімкнути центр сповіщень. WindowsScriptHost = На цьому комп'ютері вимкнено доступ до сервера сценаріїв Windows. Щоб використовувати функцію "{0}", вам необхідно увімкнути сервер сценаріїв Windows. ScheduledTaskPresented = Функцію "{0}" уже було створено від імені "{1}". diff --git a/src/Sophia_Script_for_Windows_10/Localizations/zh-CN/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Localizations/zh-CN/Sophia.psd1 index c1f1382b8..407d66aff 100644 --- a/src/Sophia_Script_for_Windows_10/Localizations/zh-CN/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Localizations/zh-CN/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = "{0}"快捷方式将被固定到开 UninstallUWPForAll = 对于所有用户 UWPAppsTitle = UWP应用 HEVCDownloading = 下载"HEVC Video Extensions from Device Manufacturer"..... -GraphicsPerformanceTitle = 图形性能偏好 -GraphicsPerformanceRequest = 是否将所选应用程序的图形性能设置设为"高性能"? +GraphicsPerformanceTitle = 是否将所选应用程序的图形性能设置设为"高性能"? ActionCenter = 为了使用"{0}"功能,你必须启用行动中心。 WindowsScriptHost = 没有在该机执行 Windows 脚本宿主的权限。请与系统管理员联系。 为了使用"{0}"功能,你必须启用Windows脚本主机。 ScheduledTaskPresented = "{0}"函数已经被创建为"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 09a14b0f4..f2a153d28 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -38,8 +38,8 @@ https://github.com/Inestic #> -#region Checks -function Checks +#region InitialActions +function InitialActions { param ( @@ -840,45 +840,130 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() - # Display a warning message about whether a user has customized the preset file - if ($Warning) + <# + .SYNOPSIS + The "Show menu" function with the up/down arrow keys and enter key to make a selection + + .EXAMPLE + Show-Menu -Menu $ListOfItems -Default $DefaultChoice + + .LINK + https://qna.habr.com/answer?answer_id=1522379 + #> + function script:Show-Menu { - # Get the name of a preset (e.g Sophia.ps1) regardless it was named - # $_.File has no EndsWith() method - $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $false)] + [string] + $Title, + + [Parameter(Mandatory = $true)] + [array] + $Menu, - $Title = "" - $Message = $Localization.CustomizationWarning -f $PresetName - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $No, $Yes - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + [Parameter(Mandatory = $true)] + [int] + $Default + ) + + Write-Information -MessageData `n$Title -InformationAction Continue + + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + $minY = [Console]::CursorTop + $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - switch ($Result) + do { - "0" + [Console]::CursorTop = $minY + [Console]::CursorLeft = 0 + $i = 0 + foreach ($item in $Menu) { - Invoke-Item -Path $PSScriptRoot\..\$PresetName + if ($i -ne $y) + { + Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue + } + else + { + Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue + } + $i++ + } - Start-Sleep -Seconds 5 + $k = [Console]::ReadKey() + switch ($k.Key) + { + "UpArrow" + { + if ($y -gt 0) + { + $y-- + } + } + "DownArrow" + { + if ($y -lt ($Menu.Count - 1)) + { + $y++ + } + } + "Enter" + { + return $Menu[$y] + } + } + } + while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) + } - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" + # Extract the localized "Browse" string from shell32.dll + $Browse = [WinAPI.GetStr]::GetString(9015) + # Extract the localized "&No" string from shell32.dll + $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + # Extract the localized "&Yes" string from shell32.dll + $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + # Extract the localized "Waiting for confirmation" string from shell32.dll + $Script:Wait = [WinAPI.GetStr]::GetString(33252) - exit - } - "1" + # Display a warning message about whether a user has customized the preset file + if ($Warning) + { + do + { + # Get the name of a preset (e.g Sophia.ps1) regardless it was named + # $_.File has no EndsWith() method + $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + $Title = $Localization.CustomizationWarning -f $PresetName + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - continue + $Yes + { + continue + } + $No + { + Invoke-Item -Path $PSScriptRoot\..\$PresetName + + Start-Sleep -Seconds 5 + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + $Wait {} } } + until ($Choice -ne $Wait) } } -#endregion Checks +#endregion InitialActions #region Protection # Enable script logging. The log will be being recorded into the script root folder @@ -1014,24 +1099,24 @@ $($Type):$($Value)`n Add-Content -Path $Path -Value $Policy -Encoding Default -Force } -# Revert back removed or commented out "Checks" functions -function script:AdditionalChecks +# Revert back removed or commented out "InitialActions" functions +function script:AdditionalActions { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method $PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")} - if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch) + if (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch) { # The string exists and is commented - if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) + if ((Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" - # Calculate the string number to uncomment "Checks -Warning" - $LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber - # Get data from the required line to replace it with "Checks -Warning" + # Calculate the string number to uncomment "InitialActions -Warning" + $LineNumber = (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).LineNumber + # Get data from the required line to replace it with "InitialActions -Warning" $RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -eq $LineNumber} - (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force + (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "InitialActions -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -1041,13 +1126,13 @@ function script:AdditionalChecks } else { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" $ReadFile = Get-Content -Path $PresetName -Encoding UTF8 - # Calculate the string number to add after "Checks -Warning" + # Calculate the string number to add after "InitialActions -Warning" $LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber # Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file - $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) + $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nInitialActions -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" @@ -1100,8 +1185,8 @@ function DiagTrackService $Enable ) - # Revert back removed or commented out "Checks" functions - AdditionalChecks + # Revert back removed or commented out "InitialActions" functions + AdditionalActions switch ($PSCmdlet.ParameterSetName) { @@ -7157,95 +7242,6 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int } } - <# - .SYNOPSIS - The "Show menu" function with the up/down arrow keys and enter key to make a selection - - .EXAMPLE - ShowMenu -Menu $ListOfItems -Default $DefaultChoice - - .LINK - https://qna.habr.com/answer?answer_id=1522379 - #> - function ShowMenu - { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $false)] - [string] - $Title, - - [Parameter(Mandatory = $true)] - [array] - $Menu, - - [Parameter(Mandatory = $true)] - [int] - $Default - ) - - Write-Information -MessageData "" -InformationAction Continue - Write-Information -MessageData $Title -InformationAction Continue - - # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count - $minY = [Console]::CursorTop - $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - - do - { - [Console]::CursorTop = $minY - [Console]::CursorLeft = 0 - $i = 0 - foreach ($item in $Menu) - { - if ($i -ne $y) - { - Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue - } - else - { - Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue - } - $i++ - } - - $k = [Console]::ReadKey() - switch ($k.Key) - { - "UpArrow" - { - if ($y -gt 0) - { - $y-- - } - } - "DownArrow" - { - if ($y -lt ($Menu.Count - 1)) - { - $y++ - } - } - "Enter" - { - # Extract the localized "Skip" string from shell32.dll - if ($Menu[$y] -eq [WinAPI.GetStr]::GetString(16956)) - { - Write-Verbose -Message $Localization.Skipped -Verbose - return - } - - return $Menu[$y] - } - } - } - while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) - } - switch ($PSCmdlet.ParameterSetName) { "Root" @@ -7253,7 +7249,7 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # Store all fixed disks' letters to use them within ShowMenu function + # Store all fixed disks' letters to use them within Show-Menu function # https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype?view=net-7.0#fields $DriveLetters = @((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object -FilterScript {$_.DriveType -eq 3}).DeviceID | Sort-Object) @@ -7271,39 +7267,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue @@ -7313,39 +7308,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue @@ -7355,39 +7349,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue @@ -7397,39 +7390,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue @@ -7439,39 +7431,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue @@ -7481,39 +7472,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Custom" { @@ -7521,247 +7511,247 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Default" { @@ -7769,175 +7759,175 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) } } } @@ -12219,21 +12209,14 @@ function Set-AppGraphicsPerformance { if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)}) { - $Title = $Localization.GraphicsPerformanceTitle - $Message = $Localization.GraphicsPerformanceRequest - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - do { - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) + $Title = $Localization.GraphicsPerformanceTitle + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - "0" + $Yes { Add-Type -AssemblyName System.Windows.Forms $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog @@ -12254,14 +12237,15 @@ function Set-AppGraphicsPerformance New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force } } - "1" + $No { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Skipped -Verbose } + $Wait {} } } - until ($Result -eq 1) + until ($Choice -ne $Wait) } } diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1 index fcf0c1f9e..45abf81c6 100644 --- a/src/Sophia_Script_for_Windows_10/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1 @@ -91,7 +91,7 @@ Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScri #> if ($Functions) { - Invoke-Command -ScriptBlock {Checks} + Invoke-Command -ScriptBlock {InitialActions} foreach ($Function in $Functions) { @@ -107,7 +107,7 @@ if ($Functions) #region Protection # The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the "-Warning" argument # Обязательные проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning" -Checks -Warning +InitialActions -Warning # Enable script logging. Log will be recorded into the script folder. To stop logging just close console or type "Stop-Transcript" # Включить логирование работы скрипта. Лог будет записываться в папку скрипта. Чтобы остановить логгирование, закройте консоль или наберите "Stop-Transcript" diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 index 1fc22b21f..2b500afa3 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 @@ -58,7 +58,7 @@ Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia -BaseDirectory $PSScriptRoot\Localizations # The mandatory checks. Please, do not comment out this function -Checks +InitialActions $Parameters = @{ CommandName = "Sophia" diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/de-DE/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/de-DE/Sophia.psd1 index 2265e21ed..0ad88fc82 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/de-DE/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/de-DE/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners UserFolderRequest = Möchten Sie den Speicherort des Ordners "{0}" ändern? UserFolderSelect = Wählen Sie einen Ordner für den Ordner "{0}". UserDefaultFolder = Möchten Sie den Speicherort des Ordners "{0}" auf den Standardwert ändern? -GraphicsPerformanceTitle = Bevorzugte Grafikleistung -GraphicsPerformanceRequest = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? +GraphicsPerformanceTitle = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Der Zugriff auf Windows Script Host wurde für diesem Computer deaktiviert. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = Die Funktion "{0}" wurde bereits als "{1}" angelegt. diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1 index cf722d2b8..8e4bba794 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = The current "{0}" folder location: " UserFolderRequest = Would you like to change the location of the "{0}" folder? UserFolderSelect = Select a folder for the "{0}" folder. UserDefaultFolder = Would you like to change the location of the "{0}" folder to the default value? -GraphicsPerformanceTitle = Graphics performance preference -GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +GraphicsPerformanceTitle = Would you like to set the graphics performance setting of an app of your choice to "High performance"? ActionCenter = In order to use "{0}" function you have to enable Action Center. WindowsScriptHost = Windows Script Host access is disabled on this machine. In order to use "{0}" function you have to enable Windows Script Host. ScheduledTaskPresented = The "{0}" function was already created as "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/es-ES/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/es-ES/Sophia.psd1 index 4613059ec..553e565e2 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/es-ES/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/es-ES/Sophia.psd1 @@ -12,7 +12,7 @@ bin = \nNo hay archivos en la carpeta bin. RebootPending = \nEl PC está esperando a ser reiniciado. UnsupportedRelease = \nUna nueva versión encontrada. CustomizationWarning = \n¿Ha personalizado todas las funciones del archivo predeterminado {0} antes de ejecutar Sophia Script? -DefenderBroken = \nMicrosoft Defender dañado o eliminado del sistema operativo. +WindowsComponentBroken = \nMicrosoft Defender dañado o eliminado del sistema operativo. UpdateDefender = \nLas definiciones de Microsoft Defender no están actualizadas. Ejecute Windows Update y vuelva a intentarlo. ControlledFolderAccessDisabled = Acceso a la carpeta controlada deshabilitado. ScheduledTasks = Tareas programadas @@ -26,8 +26,7 @@ CurrentUserFolderLocation = La ubicación actual de la carpeta " UserFolderRequest = ¿Le gustaría cambiar la ubicación de la "{0}" carpeta? UserFolderSelect = Seleccione una carpeta para la carpeta "{0}". UserDefaultFolder = ¿Le gustaría cambiar la ubicación de la carpeta "{0}" para el valor por defecto? -GraphicsPerformanceTitle = Preferencia de rendimiento gráfico -GraphicsPerformanceRequest = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? +GraphicsPerformanceTitle = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Acceso a Windows Script Host deshabilitado en este equipo. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = La función "{0}" ya fue creada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/fr-FR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/fr-FR/Sophia.psd1 index 57b682bfe..82e7cda34 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/fr-FR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/fr-FR/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = L'emplacement actuel du dossier "{0} UserFolderRequest = Voulez vous changer où est placé le dossier "{0}" ? UserFolderSelect = Sélectionnez un dossier pour le dossier "{0}". UserDefaultFolder = Voulez vous changer où est placé le dossier "{0}" à sa valeur par défaut? -GraphicsPerformanceTitle = Préférence de performances graphiques -GraphicsPerformanceRequest = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? +GraphicsPerformanceTitle = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? ActionCenter = Pour utiliser la fonction "{0}", vous devez activer le Centre d'action. WindowsScriptHost = L'accès à Windows Script Host est désactivé sur cette machine. Pour utiliser la fonction "{0}", vous devez activer Windows Script Host. ScheduledTaskPresented = La fonction "{0}" a déjà été créée en tant que "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/hu-HU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/hu-HU/Sophia.psd1 index 3e4127a13..d1c8fc415 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/hu-HU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/hu-HU/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1} UserFolderRequest = Kívánja megváltoztatni a "{0}" könyvtár helyét? UserFolderSelect = Válasszon ki egy könyvtárat a "{0}" könyvtárhoz. UserDefaultFolder = Szeretné visszaállítani a "{0}" könyvtár helyét a gyári értékekre? -GraphicsPerformanceTitle = Grafikus teljesítmény tulajdonság -GraphicsPerformanceRequest = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? +GraphicsPerformanceTitle = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? ActionCenter = Az "{0}" funkció használatához engedélyeznie kell az Action Center funkciót. WindowsScriptHost = A Windows Script Host ezen a gépen nem érhető el. Az "{0}" funkció használatához engedélyeznie kell a Windows Script Host. ScheduledTaskPresented = A "{0}" funkciót már létrehoztuk "{1}" néven. diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/it-IT/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/it-IT/Sophia.psd1 index 32e93252e..c514ac716 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/it-IT/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/it-IT/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = La posizione attuale della cartella UserFolderRequest = Volete cambiare la posizione della cartella "{0}"? UserFolderSelect = Selezionare una posizione per la cartella "{0}". UserDefaultFolder = Volete cambiare la posizione della cartella "{0}" al valore di default? -GraphicsPerformanceTitle = Preferenza per le prestazioni grafiche -GraphicsPerformanceRequest = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? +GraphicsPerformanceTitle = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? ActionCenter = Per utilizzare la funzione "{0}" è necessario attivare il Centro operativo. WindowsScriptHost = Accesso a Windows Script Host disabilitato sul computer in uso. Per utilizzare la funzione "{0}" è necessario abilitare Windows Script Host. ScheduledTaskPresented = La funzione "{0}" è già stata creata come "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pl-PL/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pl-PL/Sophia.psd1 index 2926f9aa1..8d6ec3d88 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pl-PL/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pl-PL/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{1}". UserFolderRequest = Czy chcesz zmienić lokalizację folderu "{0}"? UserFolderSelect = Wybierz folder dla folderu "{0}". UserDefaultFolder = Czy chcesz zmienić lokalizację folderu "{0}" na wartość domyślną? -GraphicsPerformanceTitle = Preferencje dotyczące wydajności grafiki -GraphicsPerformanceRequest = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? +GraphicsPerformanceTitle = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? ActionCenter = Aby korzystać z funkcji "{0}" należy włączyć Action Center. WindowsScriptHost = Dostęp do Hosta skryptów systemu Windows jest wyłączony na tym komputerze. Aby korzystać z funkcji "{0}" należy włączyć Windows Script Host. ScheduledTaskPresented = Funkcja "{0}" została już utworzona jako "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pt-BR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pt-BR/Sophia.psd1 index bc787f8f5..35e70a4a2 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pt-BR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pt-BR/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = A localização actual da pasta "{0} UserFolderRequest = Gostaria de alterar a localização da pasta "{0}"? UserFolderSelect = Selecione uma pasta para a pasta "{0}". UserDefaultFolder = Gostaria de alterar a localização da pasta "{0}" para o valor padrão? -GraphicsPerformanceTitle = Preferência de desempenho gráfico -GraphicsPerformanceRequest = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? +GraphicsPerformanceTitle = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? ActionCenter = Para utilizar a função {0}", tem de activar o Centro de Acção. WindowsScriptHost = O acesso ao Windows Script Host está desactivado neste computador. Para usar a função "{0}", é necessário ativar o Windows Script Host. ScheduledTaskPresented = A função "{0}" já foi criada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/ru-RU/Sophia.psd1 index e689b1cf7..1a5fbf5d5 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/ru-RU/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = Текущее расположен UserFolderRequest = Хотите изменить расположение папки "{0}"? UserFolderSelect = Выберите папку для "{0}". UserDefaultFolder = Хотите изменить расположение папки "{0}" на значение по умолчанию? -GraphicsPerformanceTitle = Настройка производительности графики -GraphicsPerformanceRequest = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? +GraphicsPerformanceTitle = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? ActionCenter = Чтобы использовать функцию "{0}" вам необходимо включить центр уведомлений. WindowsScriptHost = На данном компьютере отключен доступ к серверу сценариев Windows. Чтобы использовать функцию "{0}", вам необходимо включить сервер сценариев Windows. ScheduledTaskPresented = Функция "{0}" уже была создана от имени "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/tr-TR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/tr-TR/Sophia.psd1 index 7c9aae106..9f862bcbb 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/tr-TR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/tr-TR/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}" UserFolderRequest = "{0}" klasörünün yerini değiştirmek ister misiniz? UserFolderSelect = "{0}" klasörü için bir klasör seçin. UserDefaultFolder = "{0}" klasörünün konumunu varsayılan değerle değiştirmek ister misiniz? -GraphicsPerformanceTitle = Grafik performans tercihi -GraphicsPerformanceRequest = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? +GraphicsPerformanceTitle = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? ActionCenter = "{0}" işlevini kullanmak için Eylem Merkezi'ni etkinleştirmeniz gerekir. WindowsScriptHost = Windows Kod Merkezi erişimi bu makineden devre dışı. "{0}" işlevini kullanmak için Windows Kod Merkezi'u etkinleştirmeniz gerekir. ScheduledTaskPresented = "{0}" işlevi zaten "{1}" olarak oluşturulmuştu. diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/uk-UA/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/uk-UA/Sophia.psd1 index be70a1c49..6d5ed837b 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/uk-UA/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/uk-UA/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = Поточне розташуван UserFolderRequest = Бажаєте змінити розташування папки "{0}"? UserFolderSelect = Виберіть папку для "{0}". UserDefaultFolder = Бажаєте змінити розташування папки "{0}" на значення за замовчуванням? -GraphicsPerformanceTitle = Налаштування продуктивності графіки -GraphicsPerformanceRequest = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? +GraphicsPerformanceTitle = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? ScheduledTaskPresented = Функцію "{0}" уже було створено від імені "{1}". CleanupTaskNotificationTitle = Очищення Windows CleanupTaskNotificationEvent = Запустити завдання з очищення невикористовуваних файлів і оновлень Windows? diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/zh-CN/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/zh-CN/Sophia.psd1 index e6c1be407..712190c61 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/zh-CN/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/zh-CN/Sophia.psd1 @@ -26,8 +26,7 @@ CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}" UserFolderRequest = 是否要更改"{0}"文件夹位置? UserFolderSelect = 为"{0}"文件夹选择一个文件夹。 UserDefaultFolder = 您想将"{0}"文件夹的位置更改为默认值吗? -GraphicsPerformanceTitle = 图形性能偏好 -GraphicsPerformanceRequest = 是否将所选应用程序的图形性能设置设为"高性能"? +GraphicsPerformanceTitle = 是否将所选应用程序的图形性能设置设为"高性能"? ActionCenter = 为了使用"{0}"功能,你必须启用行动中心。 WindowsScriptHost = 没有在该机执行 Windows 脚本宿主的权限。请与系统管理员联系。 为了使用"{0}"功能,你必须启用Windows脚本主机。 ScheduledTaskPresented = "{0}"函数已经被创建为"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index c66950e04..049e30a76 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -38,8 +38,8 @@ https://github.com/Inestic #> -#region Checks -function Checks +#region InitialActions +function InitialActions { param ( @@ -690,45 +690,130 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() - # Display a warning message about whether a user has customized the preset file - if ($Warning) + <# + .SYNOPSIS + The "Show menu" function with the up/down arrow keys and enter key to make a selection + + .EXAMPLE + Show-Menu -Menu $ListOfItems -Default $DefaultChoice + + .LINK + https://qna.habr.com/answer?answer_id=1522379 + #> + function script:Show-Menu { - # Get the name of a preset (e.g Sophia.ps1) regardless it was named - # $_.File has no EndsWith() method - $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $false)] + [string] + $Title, - $Title = "" - $Message = $Localization.CustomizationWarning -f $PresetName - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $No, $Yes - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + [Parameter(Mandatory = $true)] + [array] + $Menu, - switch ($Result) + [Parameter(Mandatory = $true)] + [int] + $Default + ) + + Write-Information -MessageData `n$Title -InformationAction Continue + + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + $minY = [Console]::CursorTop + $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) + + do { - "0" + [Console]::CursorTop = $minY + [Console]::CursorLeft = 0 + $i = 0 + foreach ($item in $Menu) { - Invoke-Item -Path $PSScriptRoot\..\$PresetName + if ($i -ne $y) + { + Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue + } + else + { + Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue + } + $i++ + } - Start-Sleep -Seconds 5 + $k = [Console]::ReadKey() + switch ($k.Key) + { + "UpArrow" + { + if ($y -gt 0) + { + $y-- + } + } + "DownArrow" + { + if ($y -lt ($Menu.Count - 1)) + { + $y++ + } + } + "Enter" + { + return $Menu[$y] + } + } + } + while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) + } - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" + # Extract the localized "Browse" string from shell32.dll + $Browse = [WinAPI.GetStr]::GetString(9015) + # Extract the localized "&No" string from shell32.dll + $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + # Extract the localized "&Yes" string from shell32.dll + $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + # Extract the localized "Waiting for confirmation" string from shell32.dll + $Script:Wait = [WinAPI.GetStr]::GetString(33252) - exit - } - "1" + # Display a warning message about whether a user has customized the preset file + if ($Warning) + { + do + { + # Get the name of a preset (e.g Sophia.ps1) regardless it was named + # $_.File has no EndsWith() method + $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + $Title = $Localization.CustomizationWarning -f $PresetName + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - continue + $Yes + { + continue + } + $No + { + Invoke-Item -Path $PSScriptRoot\..\$PresetName + + Start-Sleep -Seconds 5 + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + $Wait {} } } + until ($Choice -ne $Wait) } } -#endregion Checks +#endregion InitialActions #region Protection # Enable script logging. The log will be being recorded into the script root folder @@ -864,24 +949,24 @@ $($Type):$($Value)`n Add-Content -Path $Path -Value $Policy -Encoding Default -Force } -# Revert back removed or commented out "Checks" functions -function script:AdditionalChecks +# Revert back removed or commented out "InitialActions" functions +function script:AdditionalActions { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method $PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")} - if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch) + if (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch) { # The string exists and is commented - if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) + if ((Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" - # Calculate the string number to uncomment "Checks -Warning" - $LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber - # Get data from the required line to replace it with "Checks -Warning" + # Calculate the string number to uncomment "InitialActions -Warning" + $LineNumber = (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).LineNumber + # Get data from the required line to replace it with "InitialActions -Warning" $RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -eq $LineNumber} - (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force + (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "InitialActions -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -891,13 +976,13 @@ function script:AdditionalChecks } else { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" $ReadFile = Get-Content -Path $PresetName -Encoding UTF8 - # Calculate the string number to add after "Checks -Warning" + # Calculate the string number to add after "InitialActions -Warning" $LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber # Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file - $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) + $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nInitialActions -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" @@ -947,8 +1032,8 @@ function DiagTrackService $Enable ) - # Revert back removed or commented out "Checks" functions - AdditionalChecks + # Revert back removed or commented out "InitialActions" functions + AdditionalActions switch ($PSCmdlet.ParameterSetName) { @@ -5794,95 +5879,6 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int } } - <# - .SYNOPSIS - The "Show menu" function with the up/down arrow keys and enter key to make a selection - - .EXAMPLE - ShowMenu -Menu $ListOfItems -Default $DefaultChoice - - .LINK - https://qna.habr.com/answer?answer_id=1522379 - #> - function ShowMenu - { - [CmdletBinding()] - param - ( - [Parameter()] - [string] - $Title, - - [Parameter(Mandatory = $true)] - [array] - $Menu, - - [Parameter(Mandatory = $true)] - [int] - $Default - ) - - Write-Information -MessageData "" -InformationAction Continue - Write-Information -MessageData $Title -InformationAction Continue - - # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count - $minY = [Console]::CursorTop - $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - - do - { - [Console]::CursorTop = $minY - [Console]::CursorLeft = 0 - $i = 0 - foreach ($item in $Menu) - { - if ($i -ne $y) - { - Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue - } - else - { - Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue - } - $i++ - } - - $k = [Console]::ReadKey() - switch ($k.Key) - { - "UpArrow" - { - if ($y -gt 0) - { - $y-- - } - } - "DownArrow" - { - if ($y -lt ($Menu.Count - 1)) - { - $y++ - } - } - "Enter" - { - # Extract the localized "Skip" string from shell32.dll - if ($Menu[$y] -eq [WinAPI.GetStr]::GetString(16956)) - { - Write-Verbose -Message $Localization.Skipped -Verbose - return - } - - return $Menu[$y] - } - } - } - while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) - } - switch ($PSCmdlet.ParameterSetName) { "Root" @@ -5890,7 +5886,7 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # Store all fixed disks' letters to use them within ShowMenu function + # Store all fixed disks' letters to use them within Show-Menu function # https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype?view=net-7.0#fields $DriveLetters = @((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object -FilterScript {$_.DriveType -eq 3}).DeviceID | Sort-Object) @@ -5908,39 +5904,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue @@ -5950,39 +5945,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue @@ -5992,39 +5986,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue @@ -6034,39 +6027,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue @@ -6076,39 +6068,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue @@ -6118,39 +6109,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Custom" { @@ -6158,247 +6148,247 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Default" { @@ -6406,175 +6396,175 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) } } } @@ -8880,21 +8870,14 @@ function Set-AppGraphicsPerformance { if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)}) { - $Title = $Localization.GraphicsPerformanceTitle - $Message = $Localization.GraphicsPerformanceRequest - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - do { - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) + $Title = $Localization.GraphicsPerformanceTitle + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - "0" + $Yes { Add-Type -AssemblyName System.Windows.Forms $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog @@ -8915,14 +8898,15 @@ function Set-AppGraphicsPerformance New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force } } - "1" + $No { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Skipped -Verbose } + $Wait {} } } - until ($Result -eq 1) + until ($Choice -ne $Wait) } } #endregion Gaming diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 index 415a14e0f..bf0e0ed58 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 @@ -91,7 +91,7 @@ Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScri #> if ($Functions) { - Invoke-Command -ScriptBlock {Checks} + Invoke-Command -ScriptBlock {InitialActions} foreach ($Function in $Functions) { @@ -107,7 +107,7 @@ if ($Functions) #region Protection # The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the "-Warning" argument # Обязательные проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning" -Checks -Warning +InitialActions -Warning # Enable script logging. Log will be recorded into the script folder. To stop logging just close console or type "Stop-Transcript" # Включить логирование работы скрипта. Лог будет записываться в папку скрипта. Чтобы остановить логгирование, закройте консоль или наберите "Stop-Transcript" diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 index 302610230..314e11090 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 @@ -58,7 +58,7 @@ Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia -BaseDirectory $PSScriptRoot\Localizations # The mandatory checks. Please, do not comment out this function -Checks +InitialActions $Parameters = @{ CommandName = "Sophia" diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/de-DE/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/de-DE/Sophia.psd1 index 15aba89a7..61e5ce0da 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/de-DE/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/de-DE/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Das Skript unterstützt nur 64-Bit-Windows. UnsupportedOSBuild = \nDas Skript unterstützt Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nIhr Windows 10-Build: {0}.{1}. Unterstützter Builds: 19044.3155+. Führen Sie Windows Update aus und versuchen Sie es erneut. +UpdateWarning = \nIhr Windows 10-Build: {0}.{1}. Unterstützter Builds: 19044.3086+. Führen Sie Windows Update aus und versuchen Sie es erneut. UnsupportedLanguageMode = \nDie PowerShell-Sitzung wird in einem eingeschränkten Sprachmodus ausgeführt. LoggedInUserNotAdmin = \nDer angemeldete Benutzer hat keine Administratorrechte. UnsupportedPowerShell = \nSie versuchen ein Skript über PowerShell {0}.{1} auszuführen. Das Skript in der entsprechenden PowerShell-Version ausführen. @@ -28,8 +28,7 @@ UserFolderSelect = Wählen Sie einen Ordner für den Or UserDefaultFolder = Möchten Sie den Speicherort des Ordners "{0}" auf den Standardwert ändern? ReservedStorageIsInUse = Dieser Vorgang wird nicht unterstützt, wenn reservierter Speicher verwendet wird\nBitte führen Sie die Funktion "{0}" nach dem PC-Neustart erneut aus. ShortcutPinning = Die Verknüpfung "{0}" wird an Start angeheftet... -GraphicsPerformanceTitle = Bevorzugte Grafikleistung -GraphicsPerformanceRequest = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? +GraphicsPerformanceTitle = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Der Zugriff auf Windows Script Host wurde für diesem Computer deaktiviert. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = Die Funktion "{0}" wurde bereits als "{1}" angelegt. diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1 index a39471d89..4f27a9828 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = The script supports 64-bit Windows only. UnsupportedOSBuild = \nThe script supports Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nYour Windows 10 build: {0}.{1}. Supported builds: 19044.3155+. Run Windows Update and try again. +UpdateWarning = \nYour Windows 10 build: {0}.{1}. Supported builds: 19044.3086+. Run Windows Update and try again. UnsupportedLanguageMode = \nThe PowerShell session in running in a limited language mode. LoggedInUserNotAdmin = \nThe logged-on user doesn't have admin rights. UnsupportedPowerShell = \nYou're trying to run script via PowerShell {0}.{1}. Run the script in the appropriate PowerShell version. @@ -28,8 +28,7 @@ UserFolderSelect = Select a folder for the "{0}" folder UserDefaultFolder = Would you like to change the location of the "{0}" folder to the default value? ReservedStorageIsInUse = This operation is not supported when reserved storage is in use\nPlease re-run the "{0}" function again after PC restart. ShortcutPinning = The "{0}" shortcut is being pinned to Start... -GraphicsPerformanceTitle = Graphics performance preference -GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +GraphicsPerformanceTitle = Would you like to set the graphics performance setting of an app of your choice to "High performance"? ActionCenter = In order to use "{0}" function you have to enable Action Center. WindowsScriptHost = Windows Script Host access is disabled on this machine. In order to use "{0}" function you have to enable Windows Script Host. ScheduledTaskPresented = The "{0}" function was already created as "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/es-ES/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/es-ES/Sophia.psd1 index 379891fcc..b5db0384a 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/es-ES/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/es-ES/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = El script sólo es compatible con Windows de 64 bits. UnsupportedOSBuild = \nEl script es compatible con versión Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nSu build de Windows 10: {0}.{1}. Compilaciones compatibles: 19044.3155+. Ejecute Windows Update y vuelva a intentarlo. +UpdateWarning = \nSu build de Windows 10: {0}.{1}. Compilaciones compatibles: 19044.3086+. Ejecute Windows Update y vuelva a intentarlo. UnsupportedLanguageMode = \nSesión de PowerShell ejecutada en modo de lenguaje limitado. LoggedInUserNotAdmin = \nEl usuario que inició sesión no tiene derechos de administrador. UnsupportedPowerShell = \nEstás intentando ejecutar el script a través de PowerShell {0}.{1}. Ejecute el script en la versión apropiada de PowerShell. @@ -28,8 +28,7 @@ UserFolderSelect = Seleccione una carpeta para la carpe UserDefaultFolder = ¿Le gustaría cambiar la ubicación de la carpeta "{0}" para el valor por defecto? ReservedStorageIsInUse = Esta operación no es compatible cuando el almacenamiento reservada está en uso\nPor favor, vuelva a ejecutar la función "{0}" después de reiniciar el PC. ShortcutPinning = El acceso directo "{0}" está siendo clavado en Start... -GraphicsPerformanceTitle = Preferencia de rendimiento gráfico -GraphicsPerformanceRequest = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? +GraphicsPerformanceTitle = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Acceso a Windows Script Host deshabilitado en este equipo. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = La función "{0}" ya fue creada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/fr-FR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/fr-FR/Sophia.psd1 index 7a8eb351c..42908cb0c 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/fr-FR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/fr-FR/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Le script n'est compatible qu'avec Windows 64 bits. UnsupportedOSBuild = \nLe script supporte les versions Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nVotre version de Windows 10 : {0}.{1}. Versions prises en charge: 19044.3155+. Exécutez Windows Update et réessayez. +UpdateWarning = \nVotre version de Windows 10 : {0}.{1}. Versions prises en charge: 19044.3086+. Exécutez Windows Update et réessayez. UnsupportedLanguageMode = \nLa session PowerShell s'exécute dans un mode de langue limité. LoggedInUserNotAdmin = \nL'utilisateur connecté n'a pas de droits d'administrateur. UnsupportedPowerShell = \nVous essayez d'exécuter le script via PowerShell {0}.{1}. Exécutez le script dans la version appropriée de PowerShell. @@ -28,8 +28,7 @@ UserFolderSelect = Sélectionnez un dossier pour le dos UserDefaultFolder = Voulez vous changer où est placé le dossier "{0}" à sa valeur par défaut? ReservedStorageIsInUse = Cette opération n'est pas suppportée le stockage réservé est en cours d'utilisation\nVeuillez réexécuter la fonction "{0}" après le redémarrage du PC. ShortcutPinning = Le raccourci "{0}" est épinglé sur Démarrer... -GraphicsPerformanceTitle = Préférence de performances graphiques -GraphicsPerformanceRequest = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? +GraphicsPerformanceTitle = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? ActionCenter = Pour utiliser la fonction "{0}", vous devez activer le Centre d'action. WindowsScriptHost = L'accès à Windows Script Host est désactivé sur cette machine. Pour utiliser la fonction "{0}", vous devez activer Windows Script Host. ScheduledTaskPresented = La fonction "{0}" a déjà été créée en tant que "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/hu-HU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/hu-HU/Sophia.psd1 index 34c9dae52..f9583071e 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/hu-HU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/hu-HU/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = A szkript csak a 64 bites Windows-t támogatja. UnsupportedOSBuild = \nA szkript támogatja a Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nAz Ön Windows 10 építése: {0}.{1}. Támogatott buildek: 19044.3155+. Futtassa a Windows Update programot, és próbálja meg újra. +UpdateWarning = \nAz Ön Windows 10 építése: {0}.{1}. Támogatott buildek: 19044.3086+. Futtassa a Windows Update programot, és próbálja meg újra. UnsupportedLanguageMode = \nA PowerShell munkamenet korlátozott nyelvi üzemmódban fut. LoggedInUserNotAdmin = \nA bejelentkezett felhasználó nem rendelkezik admin jogokkal. UnsupportedPowerShell = \nA PowerShell {0}.{1} segítségével próbálja futtatni a szkriptet. Futtassa a szkriptet a megfelelő PowerShell-verzióban. @@ -28,8 +28,7 @@ UserFolderSelect = Válasszon ki egy könyvtárat a "{0 UserDefaultFolder = Szeretné visszaállítani a "{0}" könyvtár helyét a gyári értékekre? ReservedStorageIsInUse = Ez a művelet nem hajtható végre, amíg a fenntartott tárhely használatban van\nPonovno pokrenite funkciju "{0}" nakon ponovnog pokretanja računala. ShortcutPinning = A gyorsindító ikon "{0}" Startmenüre helyezése... -GraphicsPerformanceTitle = Grafikus teljesítmény tulajdonság -GraphicsPerformanceRequest = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? +GraphicsPerformanceTitle = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? ActionCenter = Az "{0}" funkció használatához engedélyeznie kell az Action Center funkciót. WindowsScriptHost = A Windows Script Host ezen a gépen nem érhető el. Az "{0}" funkció használatához engedélyeznie kell a Windows Script Host. ScheduledTaskPresented = A "{0}" funkciót már létrehoztuk "{1}" néven. diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/it-IT/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/it-IT/Sophia.psd1 index 187ddb451..c7cb4cd7c 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/it-IT/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/it-IT/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Lo script supporta solo Windows a 64 bit. UnsupportedOSBuild = \nLo script supporta Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nLa tua build di Windows 10 {0}.{1} non è supportata. Build supportate: 19044.3155+. Eseguire Windows Update e riprovare. +UpdateWarning = \nLa tua build di Windows 10 {0}.{1} non è supportata. Build supportate: 19044.3086+. Eseguire Windows Update e riprovare. UnsupportedLanguageMode = \nLa sessione PowerShell è in esecuzione in modalità lingua limitata. LoggedInUserNotAdmin = \nL'utente in suo non ha i diritti di amministratore. UnsupportedPowerShell = \nStai cercando di eseguire lo script tramite PowerShell {0}.{1}. Esegui lo script nella versione di PowerShell appropriata. @@ -28,8 +28,7 @@ UserFolderSelect = Selezionare una posizione per la car UserDefaultFolder = Volete cambiare la posizione della cartella "{0}" al valore di default? ReservedStorageIsInUse = Questa operazione non è supportata quando spazio riservato è in uso Si prega di eseguire nuovamente la funzione "{0}" dopo il riavvio del PC. ShortcutPinning = Il collegamento "{0}" è stato bloccato... -GraphicsPerformanceTitle = Preferenza per le prestazioni grafiche -GraphicsPerformanceRequest = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? +GraphicsPerformanceTitle = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? ActionCenter = Per utilizzare la funzione "{0}" è necessario attivare il Centro operativo. WindowsScriptHost = Accesso a Windows Script Host disabilitato sul computer in uso. Per utilizzare la funzione "{0}" è necessario abilitare Windows Script Host. ScheduledTaskPresented = La funzione "{0}" è già stata creata come "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pl-PL/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pl-PL/Sophia.psd1 index 2ff0865d7..f50e3f962 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pl-PL/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pl-PL/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Skrypt obsługuje tylko 64-bitowe systemy Windows. UnsupportedOSBuild = \nSkrypt obsługuje system Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nTwoja wersja systemu Windows 10: {0}.{1}. Obsługiwane kompilacje: 19044.3155+. Uruchom aktualizację systemu Windows i spróbuj ponownie. +UpdateWarning = \nTwoja wersja systemu Windows 10: {0}.{1}. Obsługiwane kompilacje: 19044.3086+. Uruchom aktualizację systemu Windows i spróbuj ponownie. UnsupportedLanguageMode = \nSesja PowerShell działa w trybie ograniczonego języka. LoggedInUserNotAdmin = \nZalogowany użytkownik nie posiada uprawnień administratora. UnsupportedPowerShell = \nPróbujesz uruchomić skrypt przy użyciu PowerShell {0}.{1}. Uruchom skrypt używając odpowiedniej wersji PowerShell. @@ -28,8 +28,7 @@ UserFolderSelect = Wybierz folder dla folderu "{0}". UserDefaultFolder = Czy chcesz zmienić lokalizację folderu "{0}" na wartość domyślną? ReservedStorageIsInUse = Ta operacja nie jest obsługiwana, gdy używana jest zarezerwowana pamięć\nProszę ponownie uruchomić funkcję "{0}" po ponownym uruchomieniu komputera. ShortcutPinning = Skrót "{0}" jest przypinany do Start... -GraphicsPerformanceTitle = Preferencje dotyczące wydajności grafiki -GraphicsPerformanceRequest = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? +GraphicsPerformanceTitle = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? ActionCenter = Aby korzystać z funkcji "{0}" należy włączyć Action Center. WindowsScriptHost = Dostęp do Hosta skryptów systemu Windows jest wyłączony na tym komputerze. Aby korzystać z funkcji "{0}" należy włączyć Windows Script Host. ScheduledTaskPresented = Funkcja "{0}" została już utworzona jako "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pt-BR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pt-BR/Sophia.psd1 index 0f73d4ef7..38056cdfb 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pt-BR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pt-BR/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = O guião suporta apenas Windows de 64 bits. UnsupportedOSBuild = \nO script suporta versões Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nLa tua build di Windows 10: {0}.{1}. Build suportadas: 19044.3155+. Execute o Windows Update e tente novamente. +UpdateWarning = \nLa tua build di Windows 10: {0}.{1}. Build suportadas: 19044.3086+. Execute o Windows Update e tente novamente. UnsupportedLanguageMode = \nA sessão PowerShell em funcionamento em um modo de linguagem limitada. LoggedInUserNotAdmin = \nO usuário logado não tem direitos de administrador. UnsupportedPowerShell = \nVocê está tentando executar o script via PowerShell {0}.{1}. Execute o script na versão apropriada do PowerShell. @@ -28,8 +28,7 @@ UserFolderSelect = Selecione uma pasta para a pasta "{0 UserDefaultFolder = Gostaria de alterar a localização da pasta "{0}" para o valor padrão? ReservedStorageIsInUse = Esta operação não é suportada quando o armazenamento reservada está em uso\nFavor executar novamente a função "{0}" após o reinício do PC. ShortcutPinning = O atalho "{0}" está sendo fixado no Iniciar... -GraphicsPerformanceTitle = Preferência de desempenho gráfico -GraphicsPerformanceRequest = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? +GraphicsPerformanceTitle = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? ActionCenter = Para utilizar a função {0}", tem de activar o Centro de Acção. WindowsScriptHost = O acesso ao Windows Script Host está desactivado neste computador. Para usar a função "{0}", é necessário ativar o Windows Script Host. ScheduledTaskPresented = A função "{0}" já foi criada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/ru-RU/Sophia.psd1 index 8ef3b5d3e..6d39a187a 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/ru-RU/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Скрипт поддерживает только 64-битную версию Windows. UnsupportedOSBuild = \nСкрипт поддерживает только Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nВаш билд Windows 10: {0}.{1}. Поддерживаемые сборки: 19044.3155+. Запустите обновление Windows и попробуйте заново. +UpdateWarning = \nВаш билд Windows 10: {0}.{1}. Поддерживаемые сборки: 19044.3086+. Запустите обновление Windows и попробуйте заново. UnsupportedLanguageMode = \nСессия PowerShell работает в ограниченном режиме. LoggedInUserNotAdmin = \nТекущий вошедший пользователь не обладает правами администратора. UnsupportedPowerShell = \nВы пытаетесь запустить скрипт в PowerShell {0}.{1}. Запустите скрипт в соответствующей версии PowerShell. @@ -28,8 +28,7 @@ UserFolderSelect = Выберите папку для " UserDefaultFolder = Хотите изменить расположение папки "{0}" на значение по умолчанию? ReservedStorageIsInUse = Операция не поддерживается, пока используется зарезервированное хранилище\nПожалуйста, повторно запустите функцию "{0}" после перезагрузки. ShortcutPinning = Ярлык "{0}" закрепляется на начальном экране... -GraphicsPerformanceTitle = Настройка производительности графики -GraphicsPerformanceRequest = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? +GraphicsPerformanceTitle = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? ActionCenter = Чтобы использовать функцию "{0}" вам необходимо включить центр уведомлений. WindowsScriptHost = На данном компьютере отключен доступ к серверу сценариев Windows. Чтобы использовать функцию "{0}", вам необходимо включить сервер сценариев Windows. ScheduledTaskPresented = Функция "{0}" уже была создана от имени "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/tr-TR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/tr-TR/Sophia.psd1 index 85b25eabc..e4f6eca70 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/tr-TR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/tr-TR/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Komut dosyası yalnızca 64 bit Windows'u destekler. UnsupportedOSBuild = \nKomut dosyası, Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nWindows 10 yapınız: {0}.{1}. Desteklenen yapılar: 19044.3155+. Windows Update'i çalıştırın ve tekrar deneyin. +UpdateWarning = \nWindows 10 yapınız: {0}.{1}. Desteklenen yapılar: 19044.3086+. Windows Update'i çalıştırın ve tekrar deneyin. UnsupportedLanguageMode = \nSınırlı bir dil modunda çalışan PowerShell oturumu. LoggedInUserNotAdmin = \nOturum açan kullanıcının yönetici hakları yok. UnsupportedPowerShell = \nKomut dosyasını PowerShell {0}.{1} aracılığıyla çalıştırmaya çalışıyorsunuz. Komut dosyasını uygun PowerShell sürümünde çalıştırın. @@ -28,8 +28,7 @@ UserFolderSelect = "{0}" klasörü için bir klasör se UserDefaultFolder = "{0}" klasörünün konumunu varsayılan değerle değiştirmek ister misiniz? ReservedStorageIsInUse = Ayrılmış depolama kullanımdayken bu işlem desteklenmez\nBilgisayar yeniden başlatıldıktan sonra lütfen "{0}" işlevini yeniden çalıştırın. ShortcutPinning = "{0}" kısayolu Başlangıç sekmesine sabitlendi... -GraphicsPerformanceTitle = Grafik performans tercihi -GraphicsPerformanceRequest = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? +GraphicsPerformanceTitle = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? ActionCenter = "{0}" işlevini kullanmak için Eylem Merkezi'ni etkinleştirmeniz gerekir. WindowsScriptHost = Windows Kod Merkezi erişimi bu makineden devre dışı. "{0}" işlevini kullanmak için Windows Kod Merkezi'u etkinleştirmeniz gerekir. ScheduledTaskPresented = "{0}" işlevi zaten "{1}" olarak oluşturulmuştu. diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/uk-UA/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/uk-UA/Sophia.psd1 index aea7dfb06..e459903df 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/uk-UA/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/uk-UA/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = Скрипт підтримує тільки 64-розрядну версію Windows. UnsupportedOSBuild = \nСкрипт підтримує тільки Windows 10 Enterprise LTSC 2021. -UpdateWarning = \nВаш білд Windows 10: {0}.{1}. Підтримувані збірки: 19044.3155+. Запустіть Windows Update і повторіть спробу. +UpdateWarning = \nВаш білд Windows 10: {0}.{1}. Підтримувані збірки: 19044.3086+. Запустіть Windows Update і повторіть спробу. UnsupportedLanguageMode = \nСесія PowerShell працює в обмеженому режимі. LoggedInUserNotAdmin = \nПоточний користувач, що увійшов, не має прав адміністратора. UnsupportedPowerShell = \nВи намагаєтеся запустити скрипт в PowerShell {0}.{1}. Запустіть скрипт у відповідній версії PowerShell. @@ -28,8 +28,7 @@ UserFolderSelect = Виберіть папку для " UserDefaultFolder = Бажаєте змінити розташування папки "{0}" на значення за замовчуванням? ReservedStorageIsInUse = Операція не підтримується, поки використовується зарезервоване сховище\nБудь ласка, повторно запустіть функцію "{0}" після перезавантаження. ShortcutPinning = Ярлик "{0}" закріплюється на початковому екрані... -GraphicsPerformanceTitle = Налаштування продуктивності графіки -GraphicsPerformanceRequest = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? +GraphicsPerformanceTitle = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? ActionCenter = Щоб використовувати функцію "{0}" вам необхідно увімкнути центр сповіщень. WindowsScriptHost = На цьому комп'ютері вимкнено доступ до сервера сценаріїв Windows. Щоб використовувати функцію "{0}", вам необхідно увімкнути сервер сценаріїв Windows. ScheduledTaskPresented = Функцію "{0}" уже було створено від імені "{1}". diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/zh-CN/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/zh-CN/Sophia.psd1 index 7f3eafbad..dbce668ce 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/zh-CN/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/zh-CN/Sophia.psd1 @@ -1,7 +1,7 @@ ConvertFrom-StringData -StringData @' UnsupportedOSBitness = 该脚本仅支持64位Windows。 UnsupportedOSBuild = \n该脚本支持Windows 10 Enterprise LTSC 2021。 -UpdateWarning = \n您的Windows 10构建: {0}.{1}。支持的构建: 19044.3155+。运行Windows Update并再次尝试。 +UpdateWarning = \n您的Windows 10构建: {0}.{1}。支持的构建: 19044.3086+。运行Windows Update并再次尝试。 UnsupportedLanguageMode = \nPowerShell会话在有限的语言模式下运行。 LoggedInUserNotAdmin = \n登录的用户没有管理员的权利。 UnsupportedPowerShell = \n你想通过PowerShell {0}.{1}运行脚本。在适当的PowerShell版本中运行该脚本。 @@ -28,8 +28,7 @@ UserFolderSelect = 为"{0}"文件夹选择一个文件 UserDefaultFolder = 您想将"{0}"文件夹的位置更改为默认值吗? ReservedStorageIsInUse = 保留存储空间正在使用时不支持此操作\n请在电脑重启后重新运行"{0}"功能。 ShortcutPinning = "{0}"快捷方式将被固定到开始菜单..... -GraphicsPerformanceTitle = 图形性能偏好 -GraphicsPerformanceRequest = 是否将所选应用程序的图形性能设置设为"高性能"? +GraphicsPerformanceTitle = 是否将所选应用程序的图形性能设置设为"高性能"? ActionCenter = 为了使用"{0}"功能,你必须启用行动中心。 WindowsScriptHost = 没有在该机执行 Windows 脚本宿主的权限。请与系统管理员联系。 为了使用"{0}"功能,你必须启用Windows脚本主机。 ScheduledTaskPresented = "{0}"函数已经被创建为"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index 06f72ab74..f619e5db1 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -13,7 +13,7 @@ .NOTES Supported Windows 10 version Version: 21H2 - Build: 19044.3155+ + Build: 19044.3086+ Edition: Enterprise LTSC 2021 Architecture: x64 @@ -38,8 +38,8 @@ https://github.com/Inestic #> -#region Checks -function Checks +#region InitialActions +function InitialActions { param ( @@ -105,9 +105,9 @@ public static string GetString(uint strId) { $true { - if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 3155) + if ((Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR) -lt 3086) { - # Check whether the OS minor build version is 3155 minimum + # Check whether the OS minor build version is 3086 minimum # https://support.microsoft.com/en-us/help/5018682 $CurrentBuild = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name CurrentBuild $UBR = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion" -Name UBR @@ -693,45 +693,130 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() - # Display a warning message about whether a user has customized the preset file - if ($Warning) + <# + .SYNOPSIS + The "Show menu" function with the up/down arrow keys and enter key to make a selection + + .EXAMPLE + Show-Menu -Menu $ListOfItems -Default $DefaultChoice + + .LINK + https://qna.habr.com/answer?answer_id=1522379 + #> + function script:Show-Menu { - # Get the name of a preset (e.g Sophia.ps1) regardless it was named - # $_.File has no EndsWith() method - $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $false)] + [string] + $Title, - $Title = "" - $Message = $Localization.CustomizationWarning -f $PresetName - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $No, $Yes - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + [Parameter(Mandatory = $true)] + [array] + $Menu, - switch ($Result) + [Parameter(Mandatory = $true)] + [int] + $Default + ) + + Write-Information -MessageData `n$Title -InformationAction Continue + + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + $minY = [Console]::CursorTop + $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) + + do { - "0" + [Console]::CursorTop = $minY + [Console]::CursorLeft = 0 + $i = 0 + foreach ($item in $Menu) { - Invoke-Item -Path $PSScriptRoot\..\$PresetName + if ($i -ne $y) + { + Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue + } + else + { + Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue + } + $i++ + } - Start-Sleep -Seconds 5 + $k = [Console]::ReadKey() + switch ($k.Key) + { + "UpArrow" + { + if ($y -gt 0) + { + $y-- + } + } + "DownArrow" + { + if ($y -lt ($Menu.Count - 1)) + { + $y++ + } + } + "Enter" + { + return $Menu[$y] + } + } + } + while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) + } - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" + # Extract the localized "Browse" string from shell32.dll + $Browse = [WinAPI.GetStr]::GetString(9015) + # Extract the localized "&No" string from shell32.dll + $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + # Extract the localized "&Yes" string from shell32.dll + $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + # Extract the localized "Waiting for confirmation" string from shell32.dll + $Script:Wait = [WinAPI.GetStr]::GetString(33252) - exit - } - "1" + # Display a warning message about whether a user has customized the preset file + if ($Warning) + { + do + { + # Get the name of a preset (e.g Sophia.ps1) regardless it was named + # $_.File has no EndsWith() method + $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + $Title = $Localization.CustomizationWarning -f $PresetName + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - continue + $Yes + { + continue + } + $No + { + Invoke-Item -Path $PSScriptRoot\..\$PresetName + + Start-Sleep -Seconds 5 + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + $Wait {} } } + until ($Choice -ne $Wait) } } -#endregion Checks +#endregion InitialActions #region Protection # Enable script logging. The log will be being recorded into the script root folder @@ -867,24 +952,24 @@ $($Type):$($Value)`n Add-Content -Path $Path -Value $Policy -Encoding Default -Force } -# Revert back removed or commented out "Checks" functions -function script:AdditionalChecks +# Revert back removed or commented out "InitialActions" functions +function script:AdditionalActions { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method $PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")} - if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch) + if (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch) { # The string exists and is commented - if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) + if ((Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" - # Calculate the string number to uncomment "Checks -Warning" - $LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber - # Get data from the required line to replace it with "Checks -Warning" + # Calculate the string number to uncomment "InitialActions -Warning" + $LineNumber = (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).LineNumber + # Get data from the required line to replace it with "InitialActions -Warning" $RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -eq $LineNumber} - (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force + (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "InitialActions -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -894,13 +979,13 @@ function script:AdditionalChecks } else { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" $ReadFile = Get-Content -Path $PresetName -Encoding UTF8 - # Calculate the string number to add after "Checks -Warning" + # Calculate the string number to add after "InitialActions -Warning" $LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber # Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file - $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) + $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nInitialActions -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" @@ -950,8 +1035,8 @@ function DiagTrackService $Enable ) - # Revert back removed or commented out "Checks" functions - AdditionalChecks + # Revert back removed or commented out "InitialActions" functions + AdditionalActions switch ($PSCmdlet.ParameterSetName) { @@ -6184,95 +6269,6 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int } } - <# - .SYNOPSIS - The "Show menu" function with the up/down arrow keys and enter key to make a selection - - .EXAMPLE - ShowMenu -Menu $ListOfItems -Default $DefaultChoice - - .LINK - https://qna.habr.com/answer?answer_id=1522379 - #> - function ShowMenu - { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $false)] - [string] - $Title, - - [Parameter(Mandatory = $true)] - [array] - $Menu, - - [Parameter(Mandatory = $true)] - [int] - $Default - ) - - Write-Information -MessageData "" -InformationAction Continue - Write-Information -MessageData $Title -InformationAction Continue - - # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count - $minY = [Console]::CursorTop - $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - - do - { - [Console]::CursorTop = $minY - [Console]::CursorLeft = 0 - $i = 0 - foreach ($item in $Menu) - { - if ($i -ne $y) - { - Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue - } - else - { - Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue - } - $i++ - } - - $k = [Console]::ReadKey() - switch ($k.Key) - { - "UpArrow" - { - if ($y -gt 0) - { - $y-- - } - } - "DownArrow" - { - if ($y -lt ($Menu.Count - 1)) - { - $y++ - } - } - "Enter" - { - # Extract the localized "Skip" string from shell32.dll - if ($Menu[$y] -eq [WinAPI.GetStr]::GetString(16956)) - { - Write-Verbose -Message $Localization.Skipped -Verbose - return - } - - return $Menu[$y] - } - } - } - while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) - } - switch ($PSCmdlet.ParameterSetName) { "Root" @@ -6280,7 +6276,7 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # Store all fixed disks' letters to use them within ShowMenu function + # Store all fixed disks' letters to use them within Show-Menu function # https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype?view=net-7.0#fields $DriveLetters = @((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object -FilterScript {$_.DriveType -eq 3}).DeviceID | Sort-Object) @@ -6298,39 +6294,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue @@ -6340,39 +6335,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue @@ -6382,39 +6376,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue @@ -6424,39 +6417,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue @@ -6466,39 +6458,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue @@ -6508,39 +6499,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Custom" { @@ -6548,247 +6538,247 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Default" { @@ -6796,175 +6786,175 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) } } } @@ -9933,21 +9923,14 @@ function Set-AppGraphicsPerformance { if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)}) { - $Title = $Localization.GraphicsPerformanceTitle - $Message = $Localization.GraphicsPerformanceRequest - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - do { - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) + $Title = $Localization.GraphicsPerformanceTitle + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - "0" + $Yes { Add-Type -AssemblyName System.Windows.Forms $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog @@ -9968,14 +9951,15 @@ function Set-AppGraphicsPerformance New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force } } - "1" + $No { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Skipped -Verbose } + $Wait {} } } - until ($Result -eq 1) + until ($Choice -ne $Wait) } } diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 index 4b386ca13..9a8bae140 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 @@ -27,7 +27,7 @@ .NOTES Supported Windows 10 version Version: 21H2 - Build: 19044.3155+ + Build: 19044.3086+ Edition: Enterprise LTSC 2021 Architecture: x64 @@ -91,7 +91,7 @@ Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScri #> if ($Functions) { - Invoke-Command -ScriptBlock {Checks} + Invoke-Command -ScriptBlock {InitialActions} foreach ($Function in $Functions) { @@ -107,7 +107,7 @@ if ($Functions) #region Protection # The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the "-Warning" argument # Обязательные проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning" -Checks -Warning +InitialActions -Warning # Enable script logging. Log will be recorded into the script folder. To stop logging just close console or type "Stop-Transcript" # Включить логирование работы скрипта. Лог будет записываться в папку скрипта. Чтобы остановить логгирование, закройте консоль или наберите "Stop-Transcript" diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 index 84d43b43e..1da2a297f 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 @@ -65,7 +65,7 @@ catch } # The mandatory checks. Please, do not comment out this function -Checks +InitialActions $Parameters = @{ CommandName = "Sophia" diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/de-DE/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/de-DE/Sophia.psd1 index 471e6817a..837a5aeef 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/de-DE/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/de-DE/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Die Verknüpfung "{0}" wird an Start UninstallUWPForAll = Für alle Benutzer UWPAppsTitle = UWP-Apps HEVCDownloading = HEVC-Videoerweiterungen vom Gerätehersteller herunterladen... -GraphicsPerformanceTitle = Bevorzugte Grafikleistung -GraphicsPerformanceRequest = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? +GraphicsPerformanceTitle = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Der Zugriff auf Windows Script Host wurde für diesem Computer deaktiviert. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = Die Funktion "{0}" wurde bereits als "{1}" angelegt. diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1 index 164458d41..e9358bf42 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = The "{0}" shortcut is being pinned t UninstallUWPForAll = For all users UWPAppsTitle = UWP Apps HEVCDownloading = Downloading HEVC Video Extensions from Device Manufacturer... -GraphicsPerformanceTitle = Graphics performance preference -GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +GraphicsPerformanceTitle = Would you like to set the graphics performance setting of an app of your choice to "High performance"? ActionCenter = In order to use "{0}" function you have to enable Action Center. WindowsScriptHost = Windows Script Host access is disabled on this machine. In order to use "{0}" function you have to enable Windows Script Host. ScheduledTaskPresented = The "{0}" function was already created as "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/es-ES/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/es-ES/Sophia.psd1 index e3c65b048..df1ced82d 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/es-ES/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/es-ES/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = El acceso directo "{0}" está siendo UninstallUWPForAll = Para todos los usuarios UWPAppsTitle = Aplicaciones UWP HEVCDownloading = Descargando HEVC Vídeo Extensiones del Fabricante del dispositivo... -GraphicsPerformanceTitle = Preferencia de rendimiento gráfico -GraphicsPerformanceRequest = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? +GraphicsPerformanceTitle = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Acceso a Windows Script Host deshabilitado en este equipo. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = La función "{0}" ya fue creada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/fr-FR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/fr-FR/Sophia.psd1 index f134fa706..f2f50283b 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/fr-FR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/fr-FR/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Le raccourci "{0}" est épinglé sur UninstallUWPForAll = Pour tous les utilisateurs UWPAppsTitle = Applications UWP HEVCDownloading = Téléchargement de Extensions vidéo HEVC du fabricant de l'appareil... -GraphicsPerformanceTitle = Préférence de performances graphiques -GraphicsPerformanceRequest = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? +GraphicsPerformanceTitle = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? ActionCenter = Pour utiliser la fonction "{0}", vous devez activer le Centre d'action. WindowsScriptHost = L'accès à Windows Script Host est désactivé sur cette machine. Pour utiliser la fonction "{0}", vous devez activer Windows Script Host. ScheduledTaskPresented = La fonction "{0}" a déjà été créée en tant que "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/hu-HU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/hu-HU/Sophia.psd1 index 13c652857..e06c40542 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/hu-HU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/hu-HU/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = A gyorsindító ikon "{0}" Startmen UninstallUWPForAll = Az összes felhasználó számára UWPAppsTitle = UWP Alkalmazások HEVCDownloading = A HEVC Videobővítmények letöltése a gyártói oldalról... -GraphicsPerformanceTitle = Grafikus teljesítmény tulajdonság -GraphicsPerformanceRequest = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? +GraphicsPerformanceTitle = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? ActionCenter = Az "{0}" funkció használatához engedélyeznie kell az Action Center funkciót. WindowsScriptHost = A Windows Script Host ezen a gépen nem érhető el. Az "{0}" funkció használatához engedélyeznie kell a Windows Script Host. ScheduledTaskPresented = A "{0}" funkciót már létrehoztuk "{1}" néven. diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/it-IT/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/it-IT/Sophia.psd1 index 86efd6207..116d8e8a1 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/it-IT/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/it-IT/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Il collegamento "{0}" è stato blocc UninstallUWPForAll = Per tutti gli utenti UWPAppsTitle = UWP Apps HEVCDownloading = Download del codec video HEVC Video estenxion dal produttore... -GraphicsPerformanceTitle = Preferenza per le prestazioni grafiche -GraphicsPerformanceRequest = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? +GraphicsPerformanceTitle = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? ActionCenter = Per utilizzare la funzione "{0}" è necessario attivare il Centro operativo. WindowsScriptHost = Accesso a Windows Script Host disabilitato sul computer in uso. Per utilizzare la funzione "{0}" è necessario abilitare Windows Script Host. ScheduledTaskPresented = La funzione "{0}" è già stata creata come "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pl-PL/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pl-PL/Sophia.psd1 index 02bb7efaf..774a36eab 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pl-PL/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pl-PL/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Skrót "{0}" jest przypinany do Star UninstallUWPForAll = Dla wszystkich użytkowników UWPAppsTitle = Aplikacje UWP HEVCDownloading = Pobieranie rozszerzeń wideo HEVC od producenta urządzenia... -GraphicsPerformanceTitle = Preferencje dotyczące wydajności grafiki -GraphicsPerformanceRequest = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? +GraphicsPerformanceTitle = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? ActionCenter = Aby korzystać z funkcji "{0}" należy włączyć Action Center. WindowsScriptHost = Dostęp do Hosta skryptów systemu Windows jest wyłączony na tym komputerze. Aby korzystać z funkcji "{0}" należy włączyć Windows Script Host. ScheduledTaskPresented = Funkcja "{0}" została już utworzona jako "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pt-BR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pt-BR/Sophia.psd1 index ab8d24f0d..b70b4353b 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pt-BR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pt-BR/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = O atalho "{0}" está sendo fixado no UninstallUWPForAll = Para todos os usuários... UWPAppsTitle = Apps UWP HEVCDownloading = Baixando HEVC Vídeo Extensões de Dispositivo Fabricante... -GraphicsPerformanceTitle = Preferência de desempenho gráfico -GraphicsPerformanceRequest = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? +GraphicsPerformanceTitle = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? ActionCenter = Para utilizar a função {0}", tem de activar o Centro de Acção. WindowsScriptHost = O acesso ao Windows Script Host está desactivado neste computador. Para usar a função "{0}", é necessário ativar o Windows Script Host. ScheduledTaskPresented = A função "{0}" já foi criada como "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/ru-RU/Sophia.psd1 index 0c1c191fb..7c1d0f98b 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/ru-RU/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Ярлык "{0}" закрепляе UninstallUWPForAll = Для всех пользователей UWPAppsTitle = UWP-приложения HEVCDownloading = Скачивается расширение "Расширения для видео HEVC от производителя устройства"... -GraphicsPerformanceTitle = Настройка производительности графики -GraphicsPerformanceRequest = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? +GraphicsPerformanceTitle = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? ActionCenter = Чтобы использовать функцию "{0}" вам необходимо включить центр уведомлений. WindowsScriptHost = На данном компьютере отключен доступ к серверу сценариев Windows. Чтобы использовать функцию "{0}", вам необходимо включить сервер сценариев Windows. ScheduledTaskPresented = Функция "{0}" уже была создана от имени "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/tr-TR/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/tr-TR/Sophia.psd1 index 04fe033e6..d7c5774ea 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/tr-TR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/tr-TR/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = "{0}" kısayolu Başlangıç sekmesi UninstallUWPForAll = Bütün kullanıcılar için UWPAppsTitle = UWP Uygulamaları HEVCDownloading = "Cihaz Üreticisinden HEVC Video Uzantıları" İndiriliyor... -GraphicsPerformanceTitle = Grafik performans tercihi -GraphicsPerformanceRequest = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? +GraphicsPerformanceTitle = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? ActionCenter = "{0}" işlevini kullanmak için Eylem Merkezi'ni etkinleştirmeniz gerekir. WindowsScriptHost = Windows Kod Merkezi erişimi bu makineden devre dışı. "{0}" işlevini kullanmak için Windows Kod Merkezi'u etkinleştirmeniz gerekir. ScheduledTaskPresented = "{0}" işlevi zaten "{1}" olarak oluşturulmuştu. diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/uk-UA/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/uk-UA/Sophia.psd1 index f489e002d..4bf816e7f 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/uk-UA/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/uk-UA/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = Ярлик "{0}" закріплює UninstallUWPForAll = Для всіх користувачів UWPAppsTitle = UWP-додатки HEVCDownloading = Завантажується розширення "Розширення для відео HEVC від виробника пристрою"... -GraphicsPerformanceTitle = Налаштування продуктивності графіки -GraphicsPerformanceRequest = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? +GraphicsPerformanceTitle = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? ActionCenter = Щоб використовувати функцію "{0}" вам необхідно увімкнути центр сповіщень. WindowsScriptHost = На цьому комп'ютері вимкнено доступ до сервера сценаріїв Windows. Щоб використовувати функцію "{0}", вам необхідно увімкнути сервер сценаріїв Windows. ScheduledTaskPresented = Функцію "{0}" уже було створено від імені "{1}". diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/zh-CN/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/zh-CN/Sophia.psd1 index c1f1382b8..407d66aff 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/zh-CN/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/zh-CN/Sophia.psd1 @@ -35,8 +35,7 @@ ShortcutPinning = "{0}"快捷方式将被固定到开 UninstallUWPForAll = 对于所有用户 UWPAppsTitle = UWP应用 HEVCDownloading = 下载"HEVC Video Extensions from Device Manufacturer"..... -GraphicsPerformanceTitle = 图形性能偏好 -GraphicsPerformanceRequest = 是否将所选应用程序的图形性能设置设为"高性能"? +GraphicsPerformanceTitle = 是否将所选应用程序的图形性能设置设为"高性能"? ActionCenter = 为了使用"{0}"功能,你必须启用行动中心。 WindowsScriptHost = 没有在该机执行 Windows 脚本宿主的权限。请与系统管理员联系。 为了使用"{0}"功能,你必须启用Windows脚本主机。 ScheduledTaskPresented = "{0}"函数已经被创建为"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index cc43940e9..8572b5f0a 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -38,8 +38,8 @@ https://github.com/Inestic #> -#region Checks -function Checks +#region InitialActions +function InitialActions { param ( @@ -844,45 +844,130 @@ public static string GetString(uint strId) # Import PowerShell 5.1 modules Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell - # Display a warning message about whether a user has customized the preset file - if ($Warning) + <# + .SYNOPSIS + The "Show menu" function with the up/down arrow keys and enter key to make a selection + + .EXAMPLE + Show-Menu -Menu $ListOfItems -Default $DefaultChoice + + .LINK + https://qna.habr.com/answer?answer_id=1522379 + #> + function script:Show-Menu { - # Get the name of a preset (e.g Sophia.ps1) regardless it was named - # $_.File has no EndsWith() method - $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $false)] + [string] + $Title, + + [Parameter(Mandatory = $true)] + [array] + $Menu, - $Title = "" - $Message = $Localization.CustomizationWarning -f $PresetName - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $No, $Yes - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + [Parameter(Mandatory = $true)] + [int] + $Default + ) + + Write-Information -MessageData `n$Title -InformationAction Continue + + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + $minY = [Console]::CursorTop + $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - switch ($Result) + do { - "0" + [Console]::CursorTop = $minY + [Console]::CursorLeft = 0 + $i = 0 + foreach ($item in $Menu) { - Invoke-Item -Path $PSScriptRoot\..\$PresetName + if ($i -ne $y) + { + Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue + } + else + { + Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue + } + $i++ + } - Start-Sleep -Seconds 5 + $k = [Console]::ReadKey() + switch ($k.Key) + { + "UpArrow" + { + if ($y -gt 0) + { + $y-- + } + } + "DownArrow" + { + if ($y -lt ($Menu.Count - 1)) + { + $y++ + } + } + "Enter" + { + return $Menu[$y] + } + } + } + while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) + } - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" + # Extract the localized "Browse" string from shell32.dll + $Browse = [WinAPI.GetStr]::GetString(9015) + # Extract the localized "&No" string from shell32.dll + $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + # Extract the localized "&Yes" string from shell32.dll + $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + # Extract the localized "Waiting for confirmation" string from shell32.dll + $Script:Wait = [WinAPI.GetStr]::GetString(33252) - exit - } - "1" + # Display a warning message about whether a user has customized the preset file + if ($Warning) + { + do + { + # Get the name of a preset (e.g Sophia.ps1) regardless it was named + # $_.File has no EndsWith() method + $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + $Title = $Localization.CustomizationWarning -f $PresetName + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - continue + $Yes + { + continue + } + $No + { + Invoke-Item -Path $PSScriptRoot\..\$PresetName + + Start-Sleep -Seconds 5 + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + $Wait {} } } + until ($Choice -ne $Wait) } } -#endregion Checks +#endregion InitialActions #region Protection # Enable script logging. The log will be being recorded into the script root folder @@ -1018,24 +1103,24 @@ $($Type):$($Value)`n Add-Content -Path $Path -Value $Policy -Encoding Default -Force } -# Revert back removed or commented out "Checks" functions -function script:AdditionalChecks +# Revert back removed or commented out "InitialActions" functions +function script:AdditionalActions { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method $PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")} - if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch) + if (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch) { # The string exists and is commented - if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) + if ((Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" - # Calculate the string number to uncomment "Checks -Warning" - $LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber - # Get data from the required line to replace it with "Checks -Warning" + # Calculate the string number to uncomment "InitialActions -Warning" + $LineNumber = (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).LineNumber + # Get data from the required line to replace it with "InitialActions -Warning" $RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -eq $LineNumber} - (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force + (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "InitialActions -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -1045,13 +1130,13 @@ function script:AdditionalChecks } else { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" $ReadFile = Get-Content -Path $PresetName -Encoding UTF8 - # Calculate the string number to add after "Checks -Warning" + # Calculate the string number to add after "InitialActions -Warning" $LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber # Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file - $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) + $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nInitialActions -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" @@ -1104,8 +1189,8 @@ function DiagTrackService $Enable ) - # Revert back removed or commented out "Checks" functions - AdditionalChecks + # Revert back removed or commented out "InitialActions" functions + AdditionalActions switch ($PSCmdlet.ParameterSetName) { @@ -7162,95 +7247,6 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int } } - <# - .SYNOPSIS - The "Show menu" function with the up/down arrow keys and enter key to make a selection - - .EXAMPLE - ShowMenu -Menu $ListOfItems -Default $DefaultChoice - - .LINK - https://qna.habr.com/answer?answer_id=1522379 - #> - function ShowMenu - { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $false)] - [string] - $Title, - - [Parameter(Mandatory = $true)] - [array] - $Menu, - - [Parameter(Mandatory = $true)] - [int] - $Default - ) - - Write-Information -MessageData "" -InformationAction Continue - Write-Information -MessageData $Title -InformationAction Continue - - # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count - $minY = [Console]::CursorTop - $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - - do - { - [Console]::CursorTop = $minY - [Console]::CursorLeft = 0 - $i = 0 - foreach ($item in $Menu) - { - if ($i -ne $y) - { - Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue - } - else - { - Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue - } - $i++ - } - - $k = [Console]::ReadKey() - switch ($k.Key) - { - "UpArrow" - { - if ($y -gt 0) - { - $y-- - } - } - "DownArrow" - { - if ($y -lt ($Menu.Count - 1)) - { - $y++ - } - } - "Enter" - { - # Extract the localized "Skip" string from shell32.dll - if ($Menu[$y] -eq [WinAPI.GetStr]::GetString(16956)) - { - Write-Verbose -Message $Localization.Skipped -Verbose - return - } - - return $Menu[$y] - } - } - } - while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) - } - switch ($PSCmdlet.ParameterSetName) { "Root" @@ -7258,7 +7254,7 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # Store all fixed disks' letters to use them within ShowMenu function + # Store all fixed disks' letters to use them within Show-Menu function # https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype?view=net-7.0#fields $DriveLetters = @((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object -FilterScript {$_.DriveType -eq 3}).DeviceID | Sort-Object) @@ -7276,39 +7272,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue @@ -7318,39 +7313,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue @@ -7360,39 +7354,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue @@ -7402,39 +7395,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue @@ -7444,39 +7436,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue @@ -7486,39 +7477,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Custom" { @@ -7526,247 +7516,247 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Default" { @@ -7774,175 +7764,175 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) } } } @@ -12244,21 +12234,14 @@ function Set-AppGraphicsPerformance { if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)}) { - $Title = $Localization.GraphicsPerformanceTitle - $Message = $Localization.GraphicsPerformanceRequest - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - do { - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) + $Title = $Localization.GraphicsPerformanceTitle + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - "0" + $Yes { Add-Type -AssemblyName System.Windows.Forms $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog @@ -12279,14 +12262,15 @@ function Set-AppGraphicsPerformance New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force } } - "1" + $No { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Skipped -Verbose } + $Wait {} } } - until ($Result -eq 1) + until ($Choice -ne $Wait) } } diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 index 8216ab2bf..0b5e39398 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 @@ -100,7 +100,7 @@ catch #> if ($Functions) { - Invoke-Command -ScriptBlock {Checks} + Invoke-Command -ScriptBlock {InitialActions} foreach ($Function in $Functions) { @@ -116,7 +116,7 @@ if ($Functions) #region Protection # The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the "-Warning" argument # Обязательные проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning" -Checks -Warning +InitialActions -Warning # Enable script logging. Log will be recorded into the script folder. To stop logging just close console or type "Stop-Transcript" # Включить логирование работы скрипта. Лог будет записываться в папку скрипта. Чтобы остановить логгирование, закройте консоль или наберите "Stop-Transcript" diff --git a/src/Sophia_Script_for_Windows_11/Functions.ps1 b/src/Sophia_Script_for_Windows_11/Functions.ps1 index 4ca83fc64..656b75ee1 100644 --- a/src/Sophia_Script_for_Windows_11/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_11/Functions.ps1 @@ -58,7 +58,7 @@ Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force Import-LocalizedData -BindingVariable Global:Localization -FileName Sophia -BaseDirectory $PSScriptRoot\Localizations # The mandatory checks. Please, do not comment out this function -Checks +InitialActions $Parameters = @{ CommandName = "Sophia" diff --git a/src/Sophia_Script_for_Windows_11/Localizations/de-DE/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/de-DE/Sophia.psd1 index 20dea7b69..d03036af7 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/de-DE/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/de-DE/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Um Windows Subsystem für Android™ UninstallUWPForAll = Für alle Benutzer UWPAppsTitle = UWP-Apps HEVCDownloading = HEVC-Videoerweiterungen vom Gerätehersteller herunterladen... -GraphicsPerformanceTitle = Bevorzugte Grafikleistung -GraphicsPerformanceRequest = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? +GraphicsPerformanceTitle = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Der Zugriff auf Windows Script Host wurde für diesem Computer deaktiviert. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = Die Funktion "{0}" wurde bereits als "{1}" angelegt. diff --git a/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 index 9c662e74c..143a6bcad 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = To use Windows Subsystem for Android UninstallUWPForAll = For all users UWPAppsTitle = UWP Apps HEVCDownloading = Downloading HEVC Video Extensions from Device Manufacturer... -GraphicsPerformanceTitle = Graphics performance preferenc -GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +GraphicsPerformanceTitle = Would you like to set the graphics performance setting of an app of your choice to "High performance"? ActionCenter = In order to use "{0}" function you have to enable Action Center. WindowsScriptHost = Windows Script Host access is disabled on this machine. In order to use "{0}" function you have to enable Windows Script Host. ScheduledTaskPresented = The "{0}" function was already created as "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/es-ES/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/es-ES/Sophia.psd1 index 94241ee07..34dcf53b6 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/es-ES/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/es-ES/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Para utilizar Windows Subsystem for UninstallUWPForAll = Para todos los usuarios UWPAppsTitle = Aplicaciones UWP HEVCDownloading = Descargando HEVC Vídeo Extensiones del Fabricante del dispositivo... -GraphicsPerformanceTitle = Preferencia de rendimiento gráfico -GraphicsPerformanceRequest = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? +GraphicsPerformanceTitle = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Acceso a Windows Script Host deshabilitado en este equipo. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = La función "{0}" ya fue creada como "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/fr-FR/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/fr-FR/Sophia.psd1 index 8ed7b1ecb..aed7b5537 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/fr-FR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/fr-FR/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Pour utiliser le sous-système Windo UninstallUWPForAll = Pour tous les utilisateurs UWPAppsTitle = Applications UWP HEVCDownloading = Téléchargement de Extensions vidéo HEVC du fabricant de l'appareil... -GraphicsPerformanceTitle = Préférence de performances graphiques -GraphicsPerformanceRequest = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? +GraphicsPerformanceTitle = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? ActionCenter = Pour utiliser la fonction "{0}", vous devez activer le Centre d'action. WindowsScriptHost = L'accès à Windows Script Host est désactivé sur cette machine. Pour utiliser la fonction "{0}", vous devez activer Windows Script Host. ScheduledTaskPresented = La fonction "{0}" a déjà été créée en tant que "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/hu-HU/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/hu-HU/Sophia.psd1 index a8fe40cc9..67f466ee0 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/hu-HU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/hu-HU/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = A Windows Subsystem for Android™ h UninstallUWPForAll = Az összes felhasználó számára UWPAppsTitle = UWP Alkalmazások HEVCDownloading = A HEVC Videobővítmények letöltése a gyártói oldalról... -GraphicsPerformanceTitle = Grafikus teljesítmény tulajdonság -GraphicsPerformanceRequest = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? +GraphicsPerformanceTitle = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? ActionCenter = Az "{0}" funkció használatához engedélyeznie kell az Action Center funkciót. WindowsScriptHost = A Windows Script Host ezen a gépen nem érhető el. Az "{0}" funkció használatához engedélyeznie kell a Windows Script Host. ScheduledTaskPresented = A "{0}" funkciót már létrehoztuk "{1}" néven. diff --git a/src/Sophia_Script_for_Windows_11/Localizations/it-IT/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/it-IT/Sophia.psd1 index 56711b1d8..db245351c 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/it-IT/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/it-IT/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Per utilizzare Windows Subsystem for UninstallUWPForAll = Per tutti gli utenti UWPAppsTitle = UWP Apps HEVCDownloading = Download del codec video HEVC Video estenxion dal produttore... -GraphicsPerformanceTitle = Preferenza per le prestazioni grafiche -GraphicsPerformanceRequest = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? +GraphicsPerformanceTitle = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? ActionCenter = Per utilizzare la funzione "{0}" è necessario attivare il Centro operativo. WindowsScriptHost = Accesso a Windows Script Host disabilitato sul computer in uso. Per utilizzare la funzione "{0}" è necessario abilitare Windows Script Host. ScheduledTaskPresented = La funzione "{0}" è già stata creata come "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/pl-PL/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/pl-PL/Sophia.psd1 index f12da8b5b..806184dbb 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/pl-PL/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/pl-PL/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = By korzystać z podsystemu Windows d UninstallUWPForAll = Dla wszystkich użytkowników UWPAppsTitle = Aplikacje UWP HEVCDownloading = Pobieranie rozszerzeń wideo HEVC od producenta urządzenia... -GraphicsPerformanceTitle = Preferencje dotyczące wydajności grafiki -GraphicsPerformanceRequest = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? +GraphicsPerformanceTitle = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? ActionCenter = Aby korzystać z funkcji "{0}" należy włączyć Action Center. WindowsScriptHost = Dostęp do Hosta skryptów systemu Windows jest wyłączony na tym komputerze. Aby korzystać z funkcji "{0}" należy włączyć Windows Script Host. ScheduledTaskPresented = Funkcja "{0}" została już utworzona jako "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/pt-BR/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/pt-BR/Sophia.psd1 index a79797d7e..237167276 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/pt-BR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/pt-BR/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Para utilizar o Subsistema Windows p UninstallUWPForAll = Para todos os usuários... UWPAppsTitle = Apps UWP HEVCDownloading = Baixando HEVC Vídeo Extensões de Dispositivo Fabricante... -GraphicsPerformanceTitle = Preferência de desempenho gráfico -GraphicsPerformanceRequest = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? +GraphicsPerformanceTitle = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? ActionCenter = Para utilizar a função {0}", tem de activar o Centro de Acção. WindowsScriptHost = O acesso ao Windows Script Host está desactivado neste computador. Para usar a função "{0}", é necessário ativar o Windows Script Host. ScheduledTaskPresented = A função "{0}" já foi criada como "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 index 9fcc39fb0..8dc4ea212 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Чтобы использовать UninstallUWPForAll = Для всех пользователей UWPAppsTitle = UWP-приложения HEVCDownloading = Скачивается расширение "Расширения для видео HEVC от производителя устройства"... -GraphicsPerformanceTitle = Настройка производительности графики -GraphicsPerformanceRequest = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? +GraphicsPerformanceTitle = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? ActionCenter = Чтобы использовать функцию "{0}" вам необходимо включить центр уведомлений. WindowsScriptHost = На данном компьютере отключен доступ к серверу сценариев Windows. Чтобы использовать функцию "{0}", вам необходимо включить сервер сценариев Windows. ScheduledTaskPresented = Функция "{0}" уже была создана от имени "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/tr-TR/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/tr-TR/Sophia.psd1 index 30f081097..9f5adcb64 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/tr-TR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/tr-TR/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Android™ için Windows Alt Sistemi UninstallUWPForAll = Bütün kullanıcılar için UWPAppsTitle = UWP Uygulamaları HEVCDownloading = "Cihaz Üreticisinden HEVC Video Uzantıları" İndiriliyor... -GraphicsPerformanceTitle = Grafik performans tercihi -GraphicsPerformanceRequest = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? +GraphicsPerformanceTitle = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? ActionCenter = "{0}" işlevini kullanmak için Eylem Merkezi'ni etkinleştirmeniz gerekir. WindowsScriptHost = Windows Kod Merkezi erişimi bu makineden devre dışı. "{0}" işlevini kullanmak için Windows Kod Merkezi'u etkinleştirmeniz gerekir. ScheduledTaskPresented = "{0}" işlevi zaten "{1}" olarak oluşturulmuştu. diff --git a/src/Sophia_Script_for_Windows_11/Localizations/uk-UA/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/uk-UA/Sophia.psd1 index f73f6d349..d760e8e1a 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/uk-UA/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/uk-UA/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Щоб використовуват UninstallUWPForAll = Для всіх користувачів UWPAppsTitle = UWP-додатки HEVCDownloading = Завантажується розширення "Розширення для відео HEVC від виробника пристрою"... -GraphicsPerformanceTitle = Налаштування продуктивності графіки -GraphicsPerformanceRequest = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? +GraphicsPerformanceTitle = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? ActionCenter = Щоб використовувати функцію "{0}" вам необхідно увімкнути центр сповіщень. WindowsScriptHost = На цьому комп'ютері вимкнено доступ до сервера сценаріїв Windows. Щоб використовувати функцію "{0}", вам необхідно увімкнути сервер сценаріїв Windows. ScheduledTaskPresented = Функцію "{0}" уже було створено від імені "{1}". diff --git a/src/Sophia_Script_for_Windows_11/Localizations/zh-CN/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Localizations/zh-CN/Sophia.psd1 index cb4acf5ef..4dd303bff 100644 --- a/src/Sophia_Script_for_Windows_11/Localizations/zh-CN/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Localizations/zh-CN/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = 要在您的设备上使用Windows S UninstallUWPForAll = 对于所有用户 UWPAppsTitle = UWP应用 HEVCDownloading = 下载"HEVC Video Extensions from Device Manufacturer"..... -GraphicsPerformanceTitle = 图形性能偏好 -GraphicsPerformanceRequest = 是否将所选应用程序的图形性能设置设为"高性能"? +GraphicsPerformanceTitle = 是否将所选应用程序的图形性能设置设为"高性能"? ActionCenter = 为了使用"{0}"功能,你必须启用行动中心。 WindowsScriptHost = 没有在该机执行 Windows 脚本宿主的权限。请与系统管理员联系。 为了使用"{0}"功能,你必须启用Windows脚本主机。 ScheduledTaskPresented = "{0}"函数已经被创建为"{1}"。 diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 2837a2aed..eeb0816da 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -37,8 +37,8 @@ https://github.com/Inestic #> -#region Checks -function Checks +#region InitialActions +function InitialActions { param ( @@ -891,45 +891,130 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() - # Display a warning message about whether a user has customized the preset file - if ($Warning) + <# + .SYNOPSIS + The "Show menu" function with the up/down arrow keys and enter key to make a selection + + .EXAMPLE + Show-Menu -Menu $ListOfItems -Default $DefaultChoice + + .LINK + https://qna.habr.com/answer?answer_id=1522379 + #> + function script:Show-Menu { - # Get the name of a preset (e.g Sophia.ps1) regardless it was named - # $_.File has no EndsWith() method - $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $false)] + [string] + $Title, + + [Parameter(Mandatory = $true)] + [array] + $Menu, - $Title = "" - $Message = $Localization.CustomizationWarning -f $PresetName - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $No, $Yes - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + [Parameter(Mandatory = $true)] + [int] + $Default + ) + + Write-Information -MessageData `n$Title -InformationAction Continue + + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + $minY = [Console]::CursorTop + $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - switch ($Result) + do { - "0" + [Console]::CursorTop = $minY + [Console]::CursorLeft = 0 + $i = 0 + foreach ($item in $Menu) { - Invoke-Item -Path $PSScriptRoot\..\$PresetName + if ($i -ne $y) + { + Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue + } + else + { + Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue + } + $i++ + } - Start-Sleep -Seconds 5 + $k = [Console]::ReadKey() + switch ($k.Key) + { + "UpArrow" + { + if ($y -gt 0) + { + $y-- + } + } + "DownArrow" + { + if ($y -lt ($Menu.Count - 1)) + { + $y++ + } + } + "Enter" + { + return $Menu[$y] + } + } + } + while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) + } - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" + # Extract the localized "Browse" string from shell32.dll + $Browse = [WinAPI.GetStr]::GetString(9015) + # Extract the localized "&No" string from shell32.dll + $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + # Extract the localized "&Yes" string from shell32.dll + $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + # Extract the localized "Waiting for confirmation" string from shell32.dll + $Script:Wait = [WinAPI.GetStr]::GetString(33252) - exit - } - "1" + # Display a warning message about whether a user has customized the preset file + if ($Warning) + { + do + { + # Get the name of a preset (e.g Sophia.ps1) regardless it was named + # $_.File has no EndsWith() method + $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + $Title = $Localization.CustomizationWarning -f $PresetName + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - continue + $Yes + { + continue + } + $No + { + Invoke-Item -Path $PSScriptRoot\..\$PresetName + + Start-Sleep -Seconds 5 + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + $Wait {} } } + until ($Choice -ne $Wait) } } -#endregion Checks +#endregion InitialActions #region Protection # Enable script logging. The log will be being recorded into the script root folder @@ -1065,24 +1150,24 @@ $($Type):$($Value)`n Add-Content -Path $Path -Value $Policy -Encoding Default -Force } -# Revert back removed or commented out "Checks" functions -function script:AdditionalChecks +# Revert back removed or commented out "InitialActions" functions +function script:AdditionalActions { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method $PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")} - if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch) + if (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch) { # The string exists and is commented - if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) + if ((Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" - # Calculate the string number to uncomment "Checks -Warning" - $LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber - # Get data from the required line to replace it with "Checks -Warning" + # Calculate the string number to uncomment "InitialActions -Warning" + $LineNumber = (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).LineNumber + # Get data from the required line to replace it with "InitialActions -Warning" $RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -eq $LineNumber} - (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force + (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "InitialActions -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -1092,13 +1177,13 @@ function script:AdditionalChecks } else { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" $ReadFile = Get-Content -Path $PresetName -Encoding UTF8 - # Calculate the string number to add after "Checks -Warning" + # Calculate the string number to add after "InitialActions -Warning" $LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber # Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file - $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) + $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nInitialActions -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" @@ -1151,8 +1236,8 @@ function DiagTrackService $Enable ) - # Revert back removed or commented out "Checks" functions - AdditionalChecks + # Revert back removed or commented out "InitialActions" functions + AdditionalActions switch ($PSCmdlet.ParameterSetName) { @@ -7065,95 +7150,6 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int } } - <# - .SYNOPSIS - The "Show menu" function with the up/down arrow keys and enter key to make a selection - - .EXAMPLE - ShowMenu -Menu $ListOfItems -Default $DefaultChoice - - .LINK - https://qna.habr.com/answer?answer_id=1522379 - #> - function ShowMenu - { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $false)] - [string] - $Title, - - [Parameter(Mandatory = $true)] - [array] - $Menu, - - [Parameter(Mandatory = $true)] - [int] - $Default - ) - - Write-Information -MessageData "" -InformationAction Continue - Write-Information -MessageData $Title -InformationAction Continue - - # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count - $minY = [Console]::CursorTop - $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - - do - { - [Console]::CursorTop = $minY - [Console]::CursorLeft = 0 - $i = 0 - foreach ($item in $Menu) - { - if ($i -ne $y) - { - Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue - } - else - { - Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue - } - $i++ - } - - $k = [Console]::ReadKey() - switch ($k.Key) - { - "UpArrow" - { - if ($y -gt 0) - { - $y-- - } - } - "DownArrow" - { - if ($y -lt ($Menu.Count - 1)) - { - $y++ - } - } - "Enter" - { - # Extract the localized "Skip" string from shell32.dll - if ($Menu[$y] -eq [WinAPI.GetStr]::GetString(16956)) - { - Write-Verbose -Message $Localization.Skipped -Verbose - return - } - - return $Menu[$y] - } - } - } - while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) - } - switch ($PSCmdlet.ParameterSetName) { "Root" @@ -7161,7 +7157,7 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # Store all fixed disks' letters to use them within ShowMenu function + # Store all fixed disks' letters to use them within Show-Menu function # https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype?view=net-7.0#fields $DriveLetters = @((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object -FilterScript {$_.DriveType -eq 3}).DeviceID | Sort-Object) @@ -7179,39 +7175,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue @@ -7221,39 +7216,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue @@ -7263,39 +7257,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue @@ -7305,39 +7298,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue @@ -7347,39 +7339,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue @@ -7389,39 +7380,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Custom" { @@ -7429,247 +7419,247 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Default" { @@ -7677,175 +7667,175 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) } } } @@ -11878,21 +11868,14 @@ function Set-AppGraphicsPerformance { if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)}) { - $Title = $Localization.GraphicsPerformanceTitle - $Message = $Localization.GraphicsPerformanceRequest - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - do { - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) + $Title = $Localization.GraphicsPerformanceTitle + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - "0" + $Yes { Add-Type -AssemblyName System.Windows.Forms $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog @@ -11913,14 +11896,15 @@ function Set-AppGraphicsPerformance New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force } } - "1" + $No { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Skipped -Verbose } + $Wait {} } } - until ($Result -eq 1) + until ($Choice -ne $Wait) } } diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1 index 568124bee..ef56d64fa 100644 --- a/src/Sophia_Script_for_Windows_11/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1 @@ -90,7 +90,7 @@ Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScri #> if ($Functions) { - Invoke-Command -ScriptBlock {Checks} + Invoke-Command -ScriptBlock {InitialActions} foreach ($Function in $Functions) { @@ -106,7 +106,7 @@ if ($Functions) #region Protection # The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the "-Warning" argument # Обязательные проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning" -Checks -Warning +InitialActions -Warning # Enable script logging. Log will be recorded into the script folder. To stop logging just close console or type "Stop-Transcript" # Включить логирование работы скрипта. Лог будет записываться в папку скрипта. Чтобы остановить логгирование, закройте консоль или наберите "Stop-Transcript" diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 index 94727e5d3..a60fec2bf 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 @@ -65,7 +65,7 @@ catch } # The mandatory checks. Please, do not comment out this function -Checks +InitialActions $Parameters = @{ CommandName = "Sophia" diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/de-DE/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/de-DE/Sophia.psd1 index 20dea7b69..d03036af7 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/de-DE/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/de-DE/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Um Windows Subsystem für Android™ UninstallUWPForAll = Für alle Benutzer UWPAppsTitle = UWP-Apps HEVCDownloading = HEVC-Videoerweiterungen vom Gerätehersteller herunterladen... -GraphicsPerformanceTitle = Bevorzugte Grafikleistung -GraphicsPerformanceRequest = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? +GraphicsPerformanceTitle = Möchten Sie die Einstellung der Grafikleistung einer App Ihrer Wahl auf "Hohe Leistung" einstellen? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Der Zugriff auf Windows Script Host wurde für diesem Computer deaktiviert. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = Die Funktion "{0}" wurde bereits als "{1}" angelegt. diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1 index 2e1fd1f70..143a6bcad 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = To use Windows Subsystem for Android UninstallUWPForAll = For all users UWPAppsTitle = UWP Apps HEVCDownloading = Downloading HEVC Video Extensions from Device Manufacturer... -GraphicsPerformanceTitle = Graphics performance preference -GraphicsPerformanceRequest = Would you like to set the graphics performance setting of an app of your choice to "High performance"? +GraphicsPerformanceTitle = Would you like to set the graphics performance setting of an app of your choice to "High performance"? ActionCenter = In order to use "{0}" function you have to enable Action Center. WindowsScriptHost = Windows Script Host access is disabled on this machine. In order to use "{0}" function you have to enable Windows Script Host. ScheduledTaskPresented = The "{0}" function was already created as "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/es-ES/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/es-ES/Sophia.psd1 index 94241ee07..34dcf53b6 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/es-ES/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/es-ES/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Para utilizar Windows Subsystem for UninstallUWPForAll = Para todos los usuarios UWPAppsTitle = Aplicaciones UWP HEVCDownloading = Descargando HEVC Vídeo Extensiones del Fabricante del dispositivo... -GraphicsPerformanceTitle = Preferencia de rendimiento gráfico -GraphicsPerformanceRequest = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? +GraphicsPerformanceTitle = ¿Le gustaría establecer la configuración de rendimiento gráfico de una aplicación de su elección a "alto rendimiento"? ActionCenter = Um die Funktion "{0}" nutzen zu können, müssen Sie das Action Center aktivieren. WindowsScriptHost = Acceso a Windows Script Host deshabilitado en este equipo. Um die Funktion "{0}" nutzen zu können, müssen Sie den Windows Script Host aktivieren. ScheduledTaskPresented = La función "{0}" ya fue creada como "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/fr-FR/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/fr-FR/Sophia.psd1 index 8ed7b1ecb..aed7b5537 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/fr-FR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/fr-FR/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Pour utiliser le sous-système Windo UninstallUWPForAll = Pour tous les utilisateurs UWPAppsTitle = Applications UWP HEVCDownloading = Téléchargement de Extensions vidéo HEVC du fabricant de l'appareil... -GraphicsPerformanceTitle = Préférence de performances graphiques -GraphicsPerformanceRequest = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? +GraphicsPerformanceTitle = Souhaitez-vous définir le paramètre de performances graphiques d'une application de votre choix sur "Haute performance"? ActionCenter = Pour utiliser la fonction "{0}", vous devez activer le Centre d'action. WindowsScriptHost = L'accès à Windows Script Host est désactivé sur cette machine. Pour utiliser la fonction "{0}", vous devez activer Windows Script Host. ScheduledTaskPresented = La fonction "{0}" a déjà été créée en tant que "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/hu-HU/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/hu-HU/Sophia.psd1 index a8fe40cc9..67f466ee0 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/hu-HU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/hu-HU/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = A Windows Subsystem for Android™ h UninstallUWPForAll = Az összes felhasználó számára UWPAppsTitle = UWP Alkalmazások HEVCDownloading = A HEVC Videobővítmények letöltése a gyártói oldalról... -GraphicsPerformanceTitle = Grafikus teljesítmény tulajdonság -GraphicsPerformanceRequest = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? +GraphicsPerformanceTitle = Szeretné megváltoztatni a grafikus teljesítmény beállítást az ön által kiválasztott alkalmazásban "Nagy teljesítményre"? ActionCenter = Az "{0}" funkció használatához engedélyeznie kell az Action Center funkciót. WindowsScriptHost = A Windows Script Host ezen a gépen nem érhető el. Az "{0}" funkció használatához engedélyeznie kell a Windows Script Host. ScheduledTaskPresented = A "{0}" funkciót már létrehoztuk "{1}" néven. diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/it-IT/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/it-IT/Sophia.psd1 index 56711b1d8..db245351c 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/it-IT/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/it-IT/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Per utilizzare Windows Subsystem for UninstallUWPForAll = Per tutti gli utenti UWPAppsTitle = UWP Apps HEVCDownloading = Download del codec video HEVC Video estenxion dal produttore... -GraphicsPerformanceTitle = Preferenza per le prestazioni grafiche -GraphicsPerformanceRequest = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? +GraphicsPerformanceTitle = Volete impostare l'impostazione delle prestazioni grafiche di un app di vostra scelta a "Prestazioni elevate"? ActionCenter = Per utilizzare la funzione "{0}" è necessario attivare il Centro operativo. WindowsScriptHost = Accesso a Windows Script Host disabilitato sul computer in uso. Per utilizzare la funzione "{0}" è necessario abilitare Windows Script Host. ScheduledTaskPresented = La funzione "{0}" è già stata creata come "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pl-PL/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pl-PL/Sophia.psd1 index f12da8b5b..806184dbb 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pl-PL/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pl-PL/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = By korzystać z podsystemu Windows d UninstallUWPForAll = Dla wszystkich użytkowników UWPAppsTitle = Aplikacje UWP HEVCDownloading = Pobieranie rozszerzeń wideo HEVC od producenta urządzenia... -GraphicsPerformanceTitle = Preferencje dotyczące wydajności grafiki -GraphicsPerformanceRequest = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? +GraphicsPerformanceTitle = Czy chcesz ustawić wydajność grafiki wybranej aplikacji na "Wysoka wydajność"? ActionCenter = Aby korzystać z funkcji "{0}" należy włączyć Action Center. WindowsScriptHost = Dostęp do Hosta skryptów systemu Windows jest wyłączony na tym komputerze. Aby korzystać z funkcji "{0}" należy włączyć Windows Script Host. ScheduledTaskPresented = Funkcja "{0}" została już utworzona jako "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pt-BR/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pt-BR/Sophia.psd1 index 9c69344fe..e32ce6061 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pt-BR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pt-BR/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Para utilizar o Subsistema Windows p UninstallUWPForAll = Para todos os usuários... UWPAppsTitle = Apps UWP HEVCDownloading = Baixando HEVC Vídeo Extensões de Dispositivo Fabricante... -GraphicsPerformanceTitle = Preferência de desempenho gráfico -GraphicsPerformanceRequest = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? +GraphicsPerformanceTitle = Gostaria de definir a configuração de performance gráfica de um app de sua escolha para "alta performance"? ActionCenter = Para utilizar a função {0}", tem de activar o Centro de Acção. WindowsScriptHost = O acesso ao Windows Script Host está desactivado neste computador. Para usar a função "{0}", é necessário ativar o Windows Script Host. ScheduledTaskPresented = A função "{0}" já foi criada como "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/ru-RU/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/ru-RU/Sophia.psd1 index 9fcc39fb0..8dc4ea212 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/ru-RU/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/ru-RU/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Чтобы использовать UninstallUWPForAll = Для всех пользователей UWPAppsTitle = UWP-приложения HEVCDownloading = Скачивается расширение "Расширения для видео HEVC от производителя устройства"... -GraphicsPerformanceTitle = Настройка производительности графики -GraphicsPerformanceRequest = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? +GraphicsPerformanceTitle = Установить для любого приложения по вашему выбору настройки производительности графики на "Высокая производительность"? ActionCenter = Чтобы использовать функцию "{0}" вам необходимо включить центр уведомлений. WindowsScriptHost = На данном компьютере отключен доступ к серверу сценариев Windows. Чтобы использовать функцию "{0}", вам необходимо включить сервер сценариев Windows. ScheduledTaskPresented = Функция "{0}" уже была создана от имени "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/tr-TR/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/tr-TR/Sophia.psd1 index 30f081097..9f5adcb64 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/tr-TR/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/tr-TR/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Android™ için Windows Alt Sistemi UninstallUWPForAll = Bütün kullanıcılar için UWPAppsTitle = UWP Uygulamaları HEVCDownloading = "Cihaz Üreticisinden HEVC Video Uzantıları" İndiriliyor... -GraphicsPerformanceTitle = Grafik performans tercihi -GraphicsPerformanceRequest = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? +GraphicsPerformanceTitle = Seçtiğiniz bir uygulamanın grafik performansı ayarını "Yüksek performans" olarak belirlemek ister misiniz? ActionCenter = "{0}" işlevini kullanmak için Eylem Merkezi'ni etkinleştirmeniz gerekir. WindowsScriptHost = Windows Kod Merkezi erişimi bu makineden devre dışı. "{0}" işlevini kullanmak için Windows Kod Merkezi'u etkinleştirmeniz gerekir. ScheduledTaskPresented = "{0}" işlevi zaten "{1}" olarak oluşturulmuştu. diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/uk-UA/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/uk-UA/Sophia.psd1 index f73f6d349..d760e8e1a 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/uk-UA/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/uk-UA/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = Щоб використовуват UninstallUWPForAll = Для всіх користувачів UWPAppsTitle = UWP-додатки HEVCDownloading = Завантажується розширення "Розширення для відео HEVC від виробника пристрою"... -GraphicsPerformanceTitle = Налаштування продуктивності графіки -GraphicsPerformanceRequest = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? +GraphicsPerformanceTitle = Встановити для будь-якої програми за вашим вибором налаштування продуктивності графіки на "Висока продуктивність"? ActionCenter = Щоб використовувати функцію "{0}" вам необхідно увімкнути центр сповіщень. WindowsScriptHost = На цьому комп'ютері вимкнено доступ до сервера сценаріїв Windows. Щоб використовувати функцію "{0}", вам необхідно увімкнути сервер сценаріїв Windows. ScheduledTaskPresented = Функцію "{0}" уже було створено від імені "{1}". diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/zh-CN/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/zh-CN/Sophia.psd1 index cb4acf5ef..4dd303bff 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/zh-CN/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/zh-CN/Sophia.psd1 @@ -35,8 +35,7 @@ SSDRequired = 要在您的设备上使用Windows S UninstallUWPForAll = 对于所有用户 UWPAppsTitle = UWP应用 HEVCDownloading = 下载"HEVC Video Extensions from Device Manufacturer"..... -GraphicsPerformanceTitle = 图形性能偏好 -GraphicsPerformanceRequest = 是否将所选应用程序的图形性能设置设为"高性能"? +GraphicsPerformanceTitle = 是否将所选应用程序的图形性能设置设为"高性能"? ActionCenter = 为了使用"{0}"功能,你必须启用行动中心。 WindowsScriptHost = 没有在该机执行 Windows 脚本宿主的权限。请与系统管理员联系。 为了使用"{0}"功能,你必须启用Windows脚本主机。 ScheduledTaskPresented = "{0}"函数已经被创建为"{1}"。 diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index e19ed4ae2..6845d1c4c 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -37,8 +37,8 @@ https://github.com/Inestic #> -#region Checks -function Checks +#region InitialActions +function InitialActions { param ( @@ -892,48 +892,130 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() - # Import PowerShell 5.1 modules - Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell + <# + .SYNOPSIS + The "Show menu" function with the up/down arrow keys and enter key to make a selection - # Display a warning message about whether a user has customized the preset file - if ($Warning) + .EXAMPLE + Show-Menu -Menu $ListOfItems -Default $DefaultChoice + + .LINK + https://qna.habr.com/answer?answer_id=1522379 + #> + function script:Show-Menu { - # Get the name of a preset (e.g Sophia.ps1) regardless it was named - # $_.File has no EndsWith() method - $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $false)] + [string] + $Title, + + [Parameter(Mandatory = $true)] + [array] + $Menu, + + [Parameter(Mandatory = $true)] + [int] + $Default + ) - $Title = "" - $Message = $Localization.CustomizationWarning -f $PresetName - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $No, $Yes - $DefaultChoice = 0 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) + Write-Information -MessageData `n$Title -InformationAction Continue + + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + $minY = [Console]::CursorTop + $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - switch ($Result) + do { - "0" + [Console]::CursorTop = $minY + [Console]::CursorLeft = 0 + $i = 0 + foreach ($item in $Menu) { - Invoke-Item -Path $PSScriptRoot\..\$PresetName + if ($i -ne $y) + { + Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue + } + else + { + Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue + } + $i++ + } - Start-Sleep -Seconds 5 + $k = [Console]::ReadKey() + switch ($k.Key) + { + "UpArrow" + { + if ($y -gt 0) + { + $y-- + } + } + "DownArrow" + { + if ($y -lt ($Menu.Count - 1)) + { + $y++ + } + } + "Enter" + { + return $Menu[$y] + } + } + } + while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) + } - Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" - Start-Process -FilePath "https://t.me/sophia_chat" - Start-Process -FilePath "https://discord.gg/sSryhaEv79" + # Extract the localized "Browse" string from shell32.dll + $Browse = [WinAPI.GetStr]::GetString(9015) + # Extract the localized "&No" string from shell32.dll + $Script:No = [WinAPI.GetStr]::GetString(33232).Replace("&", "") + # Extract the localized "&Yes" string from shell32.dll + $Script:Yes = [WinAPI.GetStr]::GetString(33224).Replace("&", "") + # Extract the localized "Waiting for confirmation" string from shell32.dll + $Script:Wait = [WinAPI.GetStr]::GetString(33252) - exit - } - "1" + # Display a warning message about whether a user has customized the preset file + if ($Warning) + { + do + { + # Get the name of a preset (e.g Sophia.ps1) regardless it was named + # $_.File has no EndsWith() method + $PresetName = Split-Path -Path (((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")}) -Leaf + $Title = $Localization.CustomizationWarning -f $PresetName + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - continue + $Yes + { + continue + } + $No + { + Invoke-Item -Path $PSScriptRoot\..\$PresetName + + Start-Sleep -Seconds 5 + + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows#how-to-use" + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + exit + } + $Wait {} } } + until ($Choice -ne $Wait) } } -#endregion Checks +#endregion InitialActions #region Protection # Enable script logging. The log will be being recorded into the script root folder @@ -1069,24 +1151,24 @@ $($Type):$($Value)`n Add-Content -Path $Path -Value $Policy -Encoding Default -Force } -# Revert back removed or commented out "Checks" functions -function script:AdditionalChecks +# Revert back removed or commented out "InitialActions" functions +function script:AdditionalActions { # Get the name of a preset (e.g Sophia.ps1) regardless it was named # $_.File has no EndsWith() method $PresetName = ((Get-PSCallStack).Position | Where-Object -FilterScript {$_.File}).File | Where-Object -FilterScript {$_.EndsWith(".ps1")} - if (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch) + if (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch) { # The string exists and is commented - if ((Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) + if ((Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).Line.StartsWith("#") -eq $true) { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" - # Calculate the string number to uncomment "Checks -Warning" - $LineNumber = (Select-String -Path $PresetName -Pattern Checks | Select-String -Pattern "{Checks}", "The mandatory checks" -NotMatch).LineNumber - # Get data from the required line to replace it with "Checks -Warning" + # Calculate the string number to uncomment "InitialActions -Warning" + $LineNumber = (Select-String -Path $PresetName -Pattern InitialActions | Select-String -Pattern "{InitialActions}", "The mandatory checks" -NotMatch).LineNumber + # Get data from the required line to replace it with "InitialActions -Warning" $RequiredLine = (Get-Content -Path $PresetName -Encoding UTF8) | Where-Object -FilterScript {$_.ReadCount -eq $LineNumber} - (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "Checks -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force + (Get-Content -Path $PresetName -Encoding UTF8).Replace($RequiredLine, "InitialActions -Warning") | Set-Content -Path $PresetName -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" Start-Process -FilePath "https://discord.gg/sSryhaEv79" @@ -1096,13 +1178,13 @@ function script:AdditionalChecks } else { - $Host.UI.RawUI.WindowTitle = "Checks | $($PresetName)" + $Host.UI.RawUI.WindowTitle = "InitialActions | $($PresetName)" $ReadFile = Get-Content -Path $PresetName -Encoding UTF8 - # Calculate the string number to add after "Checks -Warning" + # Calculate the string number to add after "InitialActions -Warning" $LineNumber = (Select-String -Path $PresetName -Pattern Import-LocalizedData).LineNumber # Array of a new file: content before $LineNumber (including $LineNumber), new added string, the rest data of file - $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nChecks -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) + $UpdatedFile = @($ReadFile[0..($LineNumber - 1)], "`nInitialActions -Warning", $ReadFile[$LineNumber..($ReadFile.Length + 1)]) Set-Content -Path $PresetName -Value $UpdatedFile -Encoding UTF8 -Force Start-Process -FilePath "https://t.me/sophia_chat" @@ -1155,8 +1237,8 @@ function DiagTrackService $Enable ) - # Revert back removed or commented out "Checks" functions - AdditionalChecks + # Revert back removed or commented out "InitialActions" functions + AdditionalActions switch ($PSCmdlet.ParameterSetName) { @@ -7070,95 +7152,6 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int } } - <# - .SYNOPSIS - The "Show menu" function with the up/down arrow keys and enter key to make a selection - - .EXAMPLE - ShowMenu -Menu $ListOfItems -Default $DefaultChoice - - .LINK - https://qna.habr.com/answer?answer_id=1522379 - #> - function ShowMenu - { - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $false)] - [string] - $Title, - - [Parameter(Mandatory = $true)] - [array] - $Menu, - - [Parameter(Mandatory = $true)] - [int] - $Default - ) - - Write-Information -MessageData "" -InformationAction Continue - Write-Information -MessageData $Title -InformationAction Continue - - # Extract the localized "Skip" string from shell32.dll - $Menu += [WinAPI.GetStr]::GetString(16956) - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count - $minY = [Console]::CursorTop - $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) - - do - { - [Console]::CursorTop = $minY - [Console]::CursorLeft = 0 - $i = 0 - foreach ($item in $Menu) - { - if ($i -ne $y) - { - Write-Information -MessageData (' {1} ' -f ($i+1), $item) -InformationAction Continue - } - else - { - Write-Information -MessageData ('[ {1} ]' -f ($i+1), $item) -InformationAction Continue - } - $i++ - } - - $k = [Console]::ReadKey() - switch ($k.Key) - { - "UpArrow" - { - if ($y -gt 0) - { - $y-- - } - } - "DownArrow" - { - if ($y -lt ($Menu.Count - 1)) - { - $y++ - } - } - "Enter" - { - # Extract the localized "Skip" string from shell32.dll - if ($Menu[$y] -eq [WinAPI.GetStr]::GetString(16956)) - { - Write-Verbose -Message $Localization.Skipped -Verbose - return - } - - return $Menu[$y] - } - } - } - while ($k.Key -notin ([ConsoleKey]::Escape, [ConsoleKey]::Enter)) - } - switch ($PSCmdlet.ParameterSetName) { "Root" @@ -7166,7 +7159,7 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # Store all fixed disks' letters to use them within ShowMenu function + # Store all fixed disks' letters to use them within Show-Menu function # https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype?view=net-7.0#fields $DriveLetters = @((Get-CimInstance -ClassName CIM_LogicalDisk | Where-Object -FilterScript {$_.DriveType -eq 3}).DeviceID | Sort-Object) @@ -7184,39 +7177,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21769)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath "${SelectedDrive}\Desktop" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue @@ -7226,39 +7218,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath "${SelectedDrive}\Documents" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue @@ -7268,39 +7259,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) + $Yes { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21798)) -Menu $DriveLetters -Default $Script:Default - } - else - { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21770)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath "${SelectedDrive}\Downloads" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue @@ -7310,39 +7300,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21790)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath "${SelectedDrive}\Music" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue @@ -7352,39 +7341,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21779)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath "${SelectedDrive}\Pictures" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue @@ -7394,39 +7382,38 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderRequest -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - if ($DriveLetters.Count -gt 1) - { - $SelectedDrive = ShowMenu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default - } - else + $Yes { - $SelectedDrive = $env:SystemDrive - } + if ($DriveLetters.Count -gt 1) + { + $SelectedDrive = Show-Menu -Title ($Localization.DriveSelect -f [WinAPI.GetStr]::GetString(21791)) -Menu $DriveLetters -Default $Script:Default + } + else + { + $SelectedDrive = $env:SystemDrive + } - if ($SelectedDrive) + if ($SelectedDrive) + { + Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath "${SelectedDrive}\Videos" -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Custom" { @@ -7434,247 +7421,247 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browse + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "Browse" string from shell32.dll - $Browse = [WinAPI.GetStr]::GetString(9015) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = "&$Browse", $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" + $Title = $Localization.UserFolderSelect -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Browse, $No, $Wait) -Default 2 + + switch ($Choice) { - Add-Type -AssemblyName System.Windows.Forms - $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog - $FolderBrowserDialog.Description = $Localization.FolderSelect - $FolderBrowserDialog.RootFolder = "MyComputer" + $Browser + { + Add-Type -AssemblyName System.Windows.Forms + $FolderBrowserDialog = New-Object -TypeName System.Windows.Forms.FolderBrowserDialog + $FolderBrowserDialog.Description = $Localization.FolderSelect + $FolderBrowserDialog.RootFolder = "MyComputer" - # Force move the open file dialog to the foreground - $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} - $FolderBrowserDialog.ShowDialog($Focus) + # Force move the open file dialog to the foreground + $Focus = New-Object -TypeName System.Windows.Forms.Form -Property @{TopMost = $true} + $FolderBrowserDialog.ShowDialog($Focus) - if ($FolderBrowserDialog.SelectedPath) + if ($FolderBrowserDialog.SelectedPath) + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + } + } + $No { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath -RemoveDesktopINI + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose } - } - "1" - { - Write-Verbose -Message $Localization.Skipped -Verbose + $Wait {} } } + until ($Choice -ne $Wait) } "Default" { @@ -7682,175 +7669,175 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop + # Extract the localized "Desktop" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21769), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21769) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Desktop -FolderPath "$env:USERPROFILE\Desktop" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Documents Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Personal + # Extract the localized "Documents" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21770), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21770) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Documents -FolderPath "$env:USERPROFILE\Documents" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Downloads Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" + # Extract the localized "Downloads" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21798), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21798) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Downloads -FolderPath "$env:USERPROFILE\Downloads" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Music Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Music" + # Extract the localized "Music" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21790), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21790) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Music -FolderPath "$env:USERPROFILE\Music" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Pictures Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Pictures" + # Extract the localized "Pictures" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21779), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21779) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Pictures -FolderPath "$env:USERPROFILE\Pictures" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) # Videos Write-Information -MessageData "" -InformationAction Continue $CurrentUserFolderLocation = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "My Video" + # Extract the localized "Videos" string from shell32.dll Write-Verbose -Message ($Localization.CurrentUserFolderLocation -f [WinAPI.GetStr]::GetString(21791), $CurrentUserFolderLocation) -Verbose Write-Warning -Message $Localization.FilesWontBeMoved - $Title = "" - $Message = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - - switch ($Result) + do { - "0" - { - Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI - } - "1" + $Title = $Localization.UserDefaultFolder -f [WinAPI.GetStr]::GetString(21791) + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - Write-Verbose -Message $Localization.Skipped -Verbose + $Yes + { + Set-UserShellFolder -UserFolder Videos -FolderPath "$env:USERPROFILE\Videos" -RemoveDesktopINI + } + $No + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose + } + $Wait {} } } + until ($Choice -ne $Wait) } } } @@ -11903,21 +11890,14 @@ function Set-AppGraphicsPerformance { if (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)}) { - $Title = $Localization.GraphicsPerformanceTitle - $Message = $Localization.GraphicsPerformanceRequest - # Extract the localized "&Yes" string from shell32.dll - $Yes = [WinAPI.GetStr]::GetString(33224) - # Extract the localized "&No" string from shell32.dll - $No = [WinAPI.GetStr]::GetString(33232) - $Options = $Yes, $No - $DefaultChoice = 1 - do { - $Result = $Host.UI.PromptForChoice($Title, $Message, $Options, $DefaultChoice) - switch ($Result) + $Title = $Localization.GraphicsPerformanceTitle + $Choice = Show-Menu -Title $Title -Menu @($Yes, $No, $Wait) -Default 2 + + switch ($Choice) { - "0" + $Yes { Add-Type -AssemblyName System.Windows.Forms $OpenFileDialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog @@ -11938,14 +11918,15 @@ function Set-AppGraphicsPerformance New-ItemProperty -Path HKCU:\Software\Microsoft\DirectX\UserGpuPreferences -Name $OpenFileDialog.FileName -PropertyType String -Value "GpuPreference=2;" -Force } } - "1" + $No { Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message $Localization.Skipped -Verbose } + $Wait {} } } - until ($Result -eq 1) + until ($Choice -ne $Wait) } } diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 index 0c54a57d6..5faed9d97 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 @@ -99,7 +99,7 @@ catch #> if ($Functions) { - Invoke-Command -ScriptBlock {Checks} + Invoke-Command -ScriptBlock {InitialActions} foreach ($Function in $Functions) { @@ -115,7 +115,7 @@ if ($Functions) #region Protection # The mandatory checks. If you want to disable a warning message about whether the preset file was customized, remove the "-Warning" argument # Обязательные проверки. Чтобы выключить предупреждение о необходимости настройки пресет-файла, удалите аргумент "-Warning" -Checks -Warning +InitialActions -Warning # Enable script logging. Log will be recorded into the script folder. To stop logging just close console or type "Stop-Transcript" # Включить логирование работы скрипта. Лог будет записываться в папку скрипта. Чтобы остановить логгирование, закройте консоль или наберите "Stop-Transcript"