diff --git a/Wrapper/SophiaScriptWrapper.exe b/Wrapper/SophiaScriptWrapper.exe index 290db5b7e..4fc30682f 100644 Binary files a/Wrapper/SophiaScriptWrapper.exe and b/Wrapper/SophiaScriptWrapper.exe differ diff --git a/sophia_script_versions.json b/sophia_script_versions.json index a54e8f6ab..fd798a3a0 100644 --- a/sophia_script_versions.json +++ b/sophia_script_versions.json @@ -1,9 +1,9 @@ { - "Sophia_Script_Windows_10_PowerShell_5_1": "5.18.0", - "Sophia_Script_Windows_10_PowerShell_7": "5.18.0", - "Sophia_Script_Windows_10_LTSC2019": "5.8.0", - "Sophia_Script_Windows_10_LTSC2021": "5.18.0", - "Sophia_Script_Windows_11_PowerShell_5_1": "6.6.0", - "Sophia_Script_Windows_11_PowerShell_7": "6.6.0", - "Sophia_Script_Wrapper": "2.6.15" + "Sophia_Script_Windows_10_PowerShell_5_1": "5.18.1", + "Sophia_Script_Windows_10_PowerShell_7": "5.18.1", + "Sophia_Script_Windows_10_LTSC2019": "5.8.1", + "Sophia_Script_Windows_10_LTSC2021": "5.18.1", + "Sophia_Script_Windows_11_PowerShell_5_1": "6.6.1", + "Sophia_Script_Windows_11_PowerShell_7": "6.6.1", + "Sophia_Script_Wrapper": "2.6.17" } diff --git a/src/Sophia_Script_for_Windows_10/Functions.ps1 b/src/Sophia_Script_for_Windows_10/Functions.ps1 index bfae43e67..0fab62802 100644 --- a/src/Sophia_Script_for_Windows_10/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -50,7 +50,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force 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 d0c95c02f..1197bb82b 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Windows-Features OptionalFeaturesTitle = Optionale Features EnableHardwareVT = Virtualisierung in UEFI aktivieren. UserShellFolderNotEmpty = Im Ordner "{0}" befinden sich noch Dateien \nVerschieben Sie sie manuell an einen neuen Ort. +UserFolderLocationMove = Sie sollten den Speicherort des Benutzerordners nicht in das Stammverzeichnis des Laufwerks C ändern. RetrievingDrivesList = Laufwerksliste abrufen... DriveSelect = Wählen Sie das Laufwerk aus, in dessen Stammverzeichnis der Ordner "{0}" erstellt werden soll. CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners "{0}" lautet: "{1}". 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 c8169b9c5..31cc3c047 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI. UserShellFolderNotEmpty = Some files left in the "{0}" folder. Move them manually to a new location. +UserFolderLocationMove = You shouldn't change user folder location to C drive root. RetrievingDrivesList = Retrieving drives list... DriveSelect = Select the drive within the root of which the "{0}" folder will be created. CurrentUserFolderLocation = The current "{0}" folder location: "{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 9cc421b3a..d7522bd49 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Habilitar la virtualización en UEFI. UserShellFolderNotEmpty = Algunos archivos quedan en la carpeta "{0}". Moverlos manualmente a una nueva ubicación. +UserFolderLocationMove = No deberías cambiar la ubicación de la carpeta de usuario a la raíz de la unidad C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Seleccione la unidad dentro de la raíz de la cual se creó la carpeta "{0}". CurrentUserFolderLocation = La ubicación actual de la carpeta "{0}": "{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 7a6b55af7..4ede31cc6 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI. UserShellFolderNotEmpty = Certains fichiers laissés dans le dossier "{0}". Déplacer les manuellement vers un nouvel emplacement. +UserFolderLocationMove = Vous ne devez pas changer l'emplacement du dossier de l'utilisateur pour la racine du lecteur C. RetrievingDrivesList = Récupération de la liste des lecteurs... DriveSelect = Sélectionnez le disque à la racine dans lequel le dossier "{0}" sera créé. CurrentUserFolderLocation = L'emplacement actuel du dossier "{0}": "{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 559f61917..3d397616a 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Windows szolgáltatások OptionalFeaturesTitle = Opcionális szolgáltatások EnableHardwareVT = Virtualizáció engedélyezése UEFI-ben. UserShellFolderNotEmpty = Néhány fájl maradt a "{0}" könyvtárban. Kérem helyezze át ezeket egy új helyre. +UserFolderLocationMove = Nem szabad megváltoztatni a felhasználói mappa helyét a C meghajtó gyökerére. RetrievingDrivesList = A meghajtók listájának lekérése... DriveSelect = Válassza ki a meghajtó jelét a gyökérkönyvtárban ahol a "{0}" könyvtár létre lesz hozva. CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1}". 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 1e51ba7bf..0a512672a 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI. UserShellFolderNotEmpty = Alcuni file rimasti nella cartella "{0}". Spostali manualmente in una nuova posizione. +UserFolderLocationMove = Non si dovrebbe modificare la posizione della cartella utente nella radice dell'unità C. RetrievingDrivesList = Recupero lista unità... DriveSelect = Selezionare l'unità all'interno della radice del quale verrà creato la cartella "{0}" . CurrentUserFolderLocation = La posizione attuale della cartella "{0}": "{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 499b0acf2..f01a93900 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Funkcje Windows OptionalFeaturesTitle = Funkcje opcjonalne EnableHardwareVT = Włącz wirtualizację w UEFI. UserShellFolderNotEmpty = Niektóre pliki pozostały w folderze "{0}". Przenieś je ręcznie w nowe miejsce. +UserFolderLocationMove = Nie należy zmieniać lokalizacji folderu użytkownika na katalog główny dysku C. RetrievingDrivesList = Pobieranie listy dysków... DriveSelect = Wybierz dysk w katalogu głównym, w którym zostanie utworzony folder "{0}". CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{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 1d022379f..560e48e14 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI. UserShellFolderNotEmpty = Alguns arquivos deixados na pasta "{0}". Movê-los manualmente para um novo local. +UserFolderLocationMove = Você não deve alterar o local da pasta do usuário para a raiz da unidade C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Selecione a unidade dentro da raiz da qual a pasta "{0}" será criada. CurrentUserFolderLocation = A localização actual da pasta "{0}": "{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 4d440ded0..700d65b72 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI. UserShellFolderNotEmpty = В папке "{0}" остались файлы. Переместите их вручную в новое расположение. +UserFolderLocationMove = Не следует перемещать пользовательские папки в корень диска C. RetrievingDrivesList = Получение списка дисков... DriveSelect = Выберите диск, в корне которого будет создана папка "{0}". CurrentUserFolderLocation = Текущее расположение папки "{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 eeb9f2ac3..3d396b1d5 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Características do Windows OptionalFeaturesTitle = Opsiyonel özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin. UserShellFolderNotEmpty = "{0}" klasöründe bazı dosyalar kaldı. \nKendiniz yeni konuma taşıyın. +UserFolderLocationMove = Kullanıcı klasörü konumunu C sürücüsü kökü olarak değiştirmemelisiniz. RetrievingDrivesList = Sürücü listesi alınıyor... DriveSelect = "{0}" klasörünün oluşturulacağı kök içindeki sürücüyü seçin. CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}". 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 184e8cfb0..c37a25f8d 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI. UserShellFolderNotEmpty = У папці "{0}" залишилися файли. Перемістіть їх вручну в нове розташування. +UserFolderLocationMove = Не слід переміщати користувацькі папки в корінь диска C. RetrievingDrivesList = Отримання списку дисків... DriveSelect = Виберіть диск, в корні якого буде створена папка для "{0}". CurrentUserFolderLocation = Поточне розташування папки "{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 0b2f2b8ab..d01416f0c 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 @@ -28,6 +28,7 @@ WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化。 UserShellFolderNotEmpty = 一些文件留在了"{0}"文件夹。请手动将它们移到一个新位置。 +UserFolderLocationMove = 不应将用户文件夹位置更改为 C 盘根目录。 RetrievingDrivesList = 取得驱动器列表..... DriveSelect = 选择将在其根目录中创建"{0}"文件夹的驱动器。 CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1 index a8a2d14e5..195056437 100644 --- a/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.18.0' + ModuleVersion = '5.18.1' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2024 farag & Inestic. All rights reserved' diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index ecd53aef0..78664f023 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -130,6 +130,44 @@ public static string GetIndirectString(string indirectString) Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + + exit + } + } + + $Signature = @{ + Namespace = "WinAPI" + Name = "ForegroundWindow" + Language = "CSharp" + MemberDefinition = @" +[DllImport("user32.dll")] +public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + +[DllImport("user32.dll")] +[return: MarshalAs(UnmanagedType.Bool)] +public static extern bool SetForegroundWindow(IntPtr hWnd); +"@ + } + + if (-not ("WinAPI.ForegroundWindow" -as [type])) + { + try + { + Add-Type @Signature + } + catch [System.ComponentModel.Win32Exception] + { + Write-Warning -Message $Localization.NonLatinUsernameWarning + + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + exit } } @@ -1733,25 +1771,6 @@ function ScheduledTasks Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6634,25 +6653,6 @@ function WindowsFeatures Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -7027,25 +7027,6 @@ function WindowsCapabilities Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -7685,13 +7666,21 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { "Root" { - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # 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) + if ($DriveLetters.Count -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + return + } + + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose + # Desktop Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose @@ -7889,7 +7878,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7929,7 +7928,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7969,7 +7978,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -8009,7 +8028,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -8049,7 +8078,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -8089,7 +8128,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -10517,7 +10566,7 @@ function InstallDotNetRuntimes param ( [Parameter( - Mandatory = $false, + Mandatory = $true, ParameterSetName = "Runtimes" )] [ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")] @@ -11252,25 +11301,6 @@ function Install-WSL Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -12116,25 +12146,6 @@ function UninstallUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -12445,25 +12456,6 @@ function RestoreUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -13245,7 +13237,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); } `$ProcessInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo -`$ProcessInfo.FileName = """`$env:SystemRoot\System32\dism.exe""" +`$ProcessInfo.FileName = """`$env:SystemRoot\System32\Dism.exe""" `$ProcessInfo.Arguments = """/Online /English /Cleanup-Image /StartComponentCleanup /NoRestart""" `$ProcessInfo.UseShellExecute = `$true `$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized @@ -14796,58 +14788,57 @@ function WindowsSandbox $Enable ) + if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})) + { + return + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - else + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart + } + else + { + try { - try + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - } - catch [System.Exception] - { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } "Enable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - else + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart + } + else + { + try { - try - { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - } - catch [System.Exception] + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } } @@ -15060,19 +15051,21 @@ function CastToDeviceContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore } } } @@ -15115,19 +15108,21 @@ function ShareContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore } } } @@ -15170,25 +15165,29 @@ function EditWithPaint3DContext $Show ) - if (Get-AppxPackage -Name Microsoft.MSPaint) + if (-not (Get-AppxPackage -Name Microsoft.MSPaint)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + foreach ($Extension in $Extensions) { - $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") - foreach ($Extension in $Extensions) - { - New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } + New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force } - "Show" + } + "Show" + { + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + foreach ($Extension in $Extensions) { - $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") - foreach ($Extension in $Extensions) - { - Remove-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore - } + Remove-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } @@ -15232,18 +15231,20 @@ function EditWithPhotosContext $Show ) - if (Get-AppxPackage -Name Microsoft.Windows.Photos) + if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" - { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore - } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } @@ -15286,18 +15287,20 @@ function CreateANewVideoContext $Show ) - if (Get-AppxPackage -Name Microsoft.Windows.Photos) + if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" - { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore - } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } @@ -15340,18 +15343,24 @@ function ImagesEditContext $Show ) - if ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed") + if (-not ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed")) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" + if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit)) { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore + New-Item -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Force } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1 index 27e8a7d5f..371c6e113 100644 --- a/src/Sophia_Script_for_Windows_10/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10" - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -70,7 +70,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia @@ -1007,8 +1007,8 @@ UninstallPCHealthCheck InstallVCRedist <# - Install the latest .NET Desktop Runtime 6, 7 (x86/x64) - Установить последнюю версию .NET Desktop Runtime 6, 7 (x86/x64) + Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64) + Установить последнюю версию .NET Desktop Runtime 6, 7, 8 (x86/x64) https://dotnet.microsoft.com/en-us/download/dotnet #> 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 098216985..20e75ea04 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.8.0 - Date: 02.02.2024 + Version: v5.8.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -50,7 +50,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.8.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.8.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows 10 | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force 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 c90bdd19d..dfd28561d 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows-Features OptionalFeaturesTitle = Optionale Features EnableHardwareVT = Virtualisierung in UEFI aktivieren. UserShellFolderNotEmpty = Im Ordner "{0}" befinden sich noch Dateien \nVerschieben Sie sie manuell an einen neuen Ort. +UserFolderLocationMove = Sie sollten den Speicherort des Benutzerordners nicht in das Stammverzeichnis des Laufwerks C ändern. RetrievingDrivesList = Laufwerksliste abrufen... DriveSelect = Wählen Sie das Laufwerk aus, in dessen Stammverzeichnis der Ordner "{0}" erstellt werden soll. CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners "{0}" lautet: "{1}". 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 1619db3ed..421afb2e0 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI. UserShellFolderNotEmpty = Some files left in the "{0}" folder. Move them manually to a new location. +UserFolderLocationMove = You shouldn't change user folder location to C drive root. RetrievingDrivesList = Retrieving drives list... DriveSelect = Select the drive within the root of which the "{0}" folder will be created. CurrentUserFolderLocation = The current "{0}" folder location: "{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 26e68f8b6..1b72408da 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Habilitar la virtualización en UEFI. UserShellFolderNotEmpty = Algunos archivos quedan en la carpeta "{0}". Moverlos manualmente a una nueva ubicación. +UserFolderLocationMove = No deberías cambiar la ubicación de la carpeta de usuario a la raíz de la unidad C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Seleccione la unidad dentro de la raíz de la cual se creó la carpeta "{0}". CurrentUserFolderLocation = La ubicación actual de la carpeta "{0}": "{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 c3df291b8..9c624ebd4 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI. UserShellFolderNotEmpty = Certains fichiers laissés dans le dossier "{0}". Déplacer les manuellement vers un nouvel emplacement. +UserFolderLocationMove = Vous ne devez pas changer l'emplacement du dossier de l'utilisateur pour la racine du lecteur C. RetrievingDrivesList = Récupération de la liste des lecteurs... DriveSelect = Sélectionnez le disque à la racine dans lequel le dossier "{0}" sera créé. CurrentUserFolderLocation = L'emplacement actuel du dossier "{0}": "{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 db21dfe15..ab4422239 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows szolgáltatások OptionalFeaturesTitle = Opcionális szolgáltatások EnableHardwareVT = Virtualizáció engedélyezése UEFI-ben. UserShellFolderNotEmpty = Néhány fájl maradt a "{0}" könyvtárban. Kérem helyezze át ezeket egy új helyre. +UserFolderLocationMove = Nem szabad megváltoztatni a felhasználói mappa helyét a C meghajtó gyökerére. RetrievingDrivesList = A meghajtók listájának lekérése... DriveSelect = Válassza ki a meghajtó jelét a gyökérkönyvtárban ahol a "{0}" könyvtár létre lesz hozva. CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1}". 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 5c5317680..07089b269 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI. UserShellFolderNotEmpty = Alcuni file rimasti nella cartella "{0}". Spostali manualmente in una nuova posizione. +UserFolderLocationMove = Non si dovrebbe modificare la posizione della cartella utente nella radice dell'unità C. RetrievingDrivesList = Recupero lista unità... DriveSelect = Selezionare l'unità all'interno della radice del quale verrà creato la cartella "{0}" . CurrentUserFolderLocation = La posizione attuale della cartella "{0}": "{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 8a94625ee..b0e3edaf2 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Funkcje Windows OptionalFeaturesTitle = Funkcje opcjonalne EnableHardwareVT = Włącz wirtualizację w UEFI. UserShellFolderNotEmpty = Niektóre pliki pozostały w folderze "{0}". Przenieś je ręcznie w nowe miejsce. +UserFolderLocationMove = Nie należy zmieniać lokalizacji folderu użytkownika na katalog główny dysku C. RetrievingDrivesList = Pobieranie listy dysków... DriveSelect = Wybierz dysk w katalogu głównym, w którym zostanie utworzony folder "{0}". CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{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 c7a4a795a..2164afd6f 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI. UserShellFolderNotEmpty = Alguns arquivos deixados na pasta "{0}". Movê-los manualmente para um novo local. +UserFolderLocationMove = Você não deve alterar o local da pasta do usuário para a raiz da unidade C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Selecione a unidade dentro da raiz da qual a pasta "{0}" será criada. CurrentUserFolderLocation = A localização actual da pasta "{0}": "{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 96dec0b27..d354100cf 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI. UserShellFolderNotEmpty = В папке "{0}" остались файлы. Переместите их вручную в новое расположение. +UserFolderLocationMove = Не следует перемещать пользовательские папки в корень диска C. RetrievingDrivesList = Получение списка дисков... DriveSelect = Выберите диск, в корне которого будет создана папка "{0}". CurrentUserFolderLocation = Текущее расположение папки "{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 549ea0ab6..c7d513848 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Características do Windows OptionalFeaturesTitle = Opsiyonel özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin. UserShellFolderNotEmpty = "{0}" klasöründe bazı dosyalar kaldı. \nKendiniz yeni konuma taşıyın. +UserFolderLocationMove = Kullanıcı klasörü konumunu C sürücüsü kökü olarak değiştirmemelisiniz. RetrievingDrivesList = Sürücü listesi alınıyor... DriveSelect = "{0}" klasörünün oluşturulacağı kök içindeki sürücüyü seçin. CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}". 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 d0e8f9455..1c7244c4d 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI. UserShellFolderNotEmpty = У папці "{0}" залишилися файли. Перемістіть їх вручну в нове розташування. +UserFolderLocationMove = Не слід переміщати користувацькі папки в корінь диска C. RetrievingDrivesList = Отримання списку дисків... DriveSelect = Виберіть диск, в корні якого буде створена папка для "{0}". CurrentUserFolderLocation = Поточне розташування папки "{0}": "{1}". 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 0c728d722..e94120efe 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化。 UserShellFolderNotEmpty = 一些文件留在了"{0}"文件夹。请手动将它们移到一个新位置。 +UserFolderLocationMove = 不应将用户文件夹位置更改为 C 盘根目录。 RetrievingDrivesList = 取得驱动器列表..... DriveSelect = 选择将在其根目录中创建"{0}"文件夹的驱动器。 CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1 index 20f31da5d..c796b4bc2 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.8.0' + ModuleVersion = '5.8.1' GUID = 'a36a65ca-70f9-43df-856c-3048fc5e7f01' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2024 farag & Inestic. All rights reserved' 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 f1357e4af..6703233be 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 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.8.0 - Date: 02.02.2024 + Version: v5.8.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -130,6 +130,44 @@ public static string GetIndirectString(string indirectString) Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + + exit + } + } + + $Signature = @{ + Namespace = "WinAPI" + Name = "ForegroundWindow" + Language = "CSharp" + MemberDefinition = @" +[DllImport("user32.dll")] +public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + +[DllImport("user32.dll")] +[return: MarshalAs(UnmanagedType.Bool)] +public static extern bool SetForegroundWindow(IntPtr hWnd); +"@ + } + + if (-not ("WinAPI.ForegroundWindow" -as [type])) + { + try + { + Add-Type @Signature + } + catch [System.ComponentModel.Win32Exception] + { + Write-Warning -Message $Localization.NonLatinUsernameWarning + + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + exit } } @@ -1608,26 +1646,7 @@ function ScheduledTasks Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - - Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC")} | ForEach-Object -Process { + Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC 2019")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -5272,26 +5291,7 @@ function WindowsFeatures Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - - Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC")} | ForEach-Object -Process { + Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC 2019")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -5650,26 +5650,7 @@ function WindowsCapabilities Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - - Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC")} | ForEach-Object -Process { + Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC 2019")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6308,13 +6289,21 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { "Root" { - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # 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) + if ($DriveLetters.Count -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + return + } + + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose + # Desktop Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose @@ -6512,7 +6501,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6552,7 +6551,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6592,7 +6601,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6632,7 +6651,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6672,7 +6701,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6712,7 +6751,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -8744,7 +8793,7 @@ function InstallDotNetRuntimes param ( [Parameter( - Mandatory = $false, + Mandatory = $true, ParameterSetName = "Runtimes" )] [ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")] @@ -9711,7 +9760,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); } `$ProcessInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo -`$ProcessInfo.FileName = """`$env:SystemRoot\System32\dism.exe""" +`$ProcessInfo.FileName = """`$env:SystemRoot\System32\Dism.exe""" `$ProcessInfo.Arguments = """/Online /English /Cleanup-Image /StartComponentCleanup /NoRestart""" `$ProcessInfo.UseShellExecute = `$true `$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized @@ -11262,58 +11311,57 @@ function WindowsSandbox $Enable ) + if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})) + { + return + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - else + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart + } + else + { + try { - try + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - } - catch [System.Exception] - { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } "Enable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - else + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart + } + else + { + try { - try + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - } - catch [System.Exception] - { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } } @@ -11526,19 +11574,21 @@ function CastToDeviceContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore } } } @@ -11581,19 +11631,21 @@ function ShareContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore } } } @@ -11636,6 +11688,13 @@ function EditWithPaint3DContext $Show ) + if (-not (Get-AppxPackage -Name Microsoft.MSPaint)) + { + return + } + + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + switch ($PSCmdlet.ParameterSetName) { "Hide" 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 d9323590e..cb6307dc5 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10 LTSC 2019" - Version: v5.8.0 - Date: 02.02.2024 + Version: v5.8.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -70,7 +70,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.8.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2019 v5.8.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia @@ -788,8 +788,8 @@ ActiveHours -Automatically InstallVCRedist <# - Install the latest .NET Desktop Runtime 6, 7 (x86/x64) - Установить последнюю версию .NET Desktop Runtime 6, 7 (x86/x64) + Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64) + Установить последнюю версию .NET Desktop Runtime 6, 7, 8 (x86/x64) https://dotnet.microsoft.com/en-us/download/dotnet #> 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 a041ee7b0..1b78d58f4 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -50,7 +50,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.18.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.18.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force 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 3599471a3..6a3cd5ffa 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows-Features OptionalFeaturesTitle = Optionale Features EnableHardwareVT = Virtualisierung in UEFI aktivieren. UserShellFolderNotEmpty = Im Ordner "{0}" befinden sich noch Dateien \nVerschieben Sie sie manuell an einen neuen Ort. +UserFolderLocationMove = Sie sollten den Speicherort des Benutzerordners nicht in das Stammverzeichnis des Laufwerks C ändern. RetrievingDrivesList = Laufwerksliste abrufen... DriveSelect = Wählen Sie das Laufwerk aus, in dessen Stammverzeichnis der Ordner "{0}" erstellt werden soll. CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners "{0}" lautet: "{1}". 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 251e3f591..522bc9baa 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI. UserShellFolderNotEmpty = Some files left in the "{0}" folder. Move them manually to a new location. +UserFolderLocationMove = You shouldn't change user folder location to C drive root. RetrievingDrivesList = Retrieving drives list... DriveSelect = Select the drive within the root of which the "{0}" folder will be created. CurrentUserFolderLocation = The current "{0}" folder location: "{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 5b33f9512..75b831c48 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Habilitar la virtualización en UEFI. UserShellFolderNotEmpty = Algunos archivos quedan en la carpeta "{0}". Moverlos manualmente a una nueva ubicación. +UserFolderLocationMove = No deberías cambiar la ubicación de la carpeta de usuario a la raíz de la unidad C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Seleccione la unidad dentro de la raíz de la cual se creó la carpeta "{0}". CurrentUserFolderLocation = La ubicación actual de la carpeta "{0}": "{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 9598682ae..1b583dbc7 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI. UserShellFolderNotEmpty = Certains fichiers laissés dans le dossier "{0}". Déplacer les manuellement vers un nouvel emplacement. +UserFolderLocationMove = Vous ne devez pas changer l'emplacement du dossier de l'utilisateur pour la racine du lecteur C. RetrievingDrivesList = Récupération de la liste des lecteurs... DriveSelect = Sélectionnez le disque à la racine dans lequel le dossier "{0}" sera créé. CurrentUserFolderLocation = L'emplacement actuel du dossier "{0}": "{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 b68264f17..8f8dd58d4 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows szolgáltatások OptionalFeaturesTitle = Opcionális szolgáltatások EnableHardwareVT = Virtualizáció engedélyezése UEFI-ben. UserShellFolderNotEmpty = Néhány fájl maradt a "{0}" könyvtárban. Kérem helyezze át ezeket egy új helyre. +UserFolderLocationMove = Nem szabad megváltoztatni a felhasználói mappa helyét a C meghajtó gyökerére. RetrievingDrivesList = A meghajtók listájának lekérése... DriveSelect = Válassza ki a meghajtó jelét a gyökérkönyvtárban ahol a "{0}" könyvtár létre lesz hozva. CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1}". 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 8e9e9e032..5cb96833f 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI. UserShellFolderNotEmpty = Alcuni file rimasti nella cartella "{0}". Spostali manualmente in una nuova posizione. +UserFolderLocationMove = Non si dovrebbe modificare la posizione della cartella utente nella radice dell'unità C. RetrievingDrivesList = Recupero lista unità... DriveSelect = Selezionare l'unità all'interno della radice del quale verrà creato la cartella "{0}" . CurrentUserFolderLocation = La posizione attuale della cartella "{0}": "{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 828fb4489..1bbfdb20a 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Funkcje Windows OptionalFeaturesTitle = Funkcje opcjonalne EnableHardwareVT = Włącz wirtualizację w UEFI. UserShellFolderNotEmpty = Niektóre pliki pozostały w folderze "{0}". Przenieś je ręcznie w nowe miejsce. +UserFolderLocationMove = Nie należy zmieniać lokalizacji folderu użytkownika na katalog główny dysku C. RetrievingDrivesList = Pobieranie listy dysków... DriveSelect = Wybierz dysk w katalogu głównym, w którym zostanie utworzony folder "{0}". CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{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 22ef28d7e..4e9c04003 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI. UserShellFolderNotEmpty = Alguns arquivos deixados na pasta "{0}". Movê-los manualmente para um novo local. +UserFolderLocationMove = Você não deve alterar o local da pasta do usuário para a raiz da unidade C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Selecione a unidade dentro da raiz da qual a pasta "{0}" será criada. CurrentUserFolderLocation = A localização actual da pasta "{0}": "{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 a73af5408..081d65497 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI. UserShellFolderNotEmpty = В папке "{0}" остались файлы. Переместите их вручную в новое расположение. +UserFolderLocationMove = Не следует перемещать пользовательские папки в корень диска C. RetrievingDrivesList = Получение списка дисков... DriveSelect = Выберите диск, в корне которого будет создана папка "{0}". CurrentUserFolderLocation = Текущее расположение папки "{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 54f3da65e..f11f1debb 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Características do Windows OptionalFeaturesTitle = Opsiyonel özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin. UserShellFolderNotEmpty = "{0}" klasöründe bazı dosyalar kaldı. \nKendiniz yeni konuma taşıyın. +UserFolderLocationMove = Kullanıcı klasörü konumunu C sürücüsü kökü olarak değiştirmemelisiniz. RetrievingDrivesList = Sürücü listesi alınıyor... DriveSelect = "{0}" klasörünün oluşturulacağı kök içindeki sürücüyü seçin. CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}". 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 5a34eba59..0d22d7c0c 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI. UserShellFolderNotEmpty = У папці "{0}" залишилися файли. Перемістіть їх вручну в нове розташування. +UserFolderLocationMove = Не слід переміщати користувацькі папки в корінь диска C. RetrievingDrivesList = Отримання списку дисків... DriveSelect = Виберіть диск, в корні якого буде створена папка для "{0}". CurrentUserFolderLocation = Поточне розташування папки "{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 c9df98b64..6616ccdc6 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 @@ -24,6 +24,7 @@ WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化。 UserShellFolderNotEmpty = 一些文件留在了"{0}"文件夹。请手动将它们移到一个新位置。 +UserFolderLocationMove = 不应将用户文件夹位置更改为 C 盘根目录。 RetrievingDrivesList = 取得驱动器列表..... DriveSelect = 选择将在其根目录中创建"{0}"文件夹的驱动器。 CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1 index a8a2d14e5..195056437 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.18.0' + ModuleVersion = '5.18.1' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2024 farag & Inestic. All rights reserved' 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 52f2c451b..1c80677c5 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 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -130,6 +130,44 @@ public static string GetIndirectString(string indirectString) Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + + exit + } + } + + $Signature = @{ + Namespace = "WinAPI" + Name = "ForegroundWindow" + Language = "CSharp" + MemberDefinition = @" +[DllImport("user32.dll")] +public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + +[DllImport("user32.dll")] +[return: MarshalAs(UnmanagedType.Bool)] +public static extern bool SetForegroundWindow(IntPtr hWnd); +"@ + } + + if (-not ("WinAPI.ForegroundWindow" -as [type])) + { + try + { + Add-Type @Signature + } + catch [System.ComponentModel.Win32Exception] + { + Write-Warning -Message $Localization.NonLatinUsernameWarning + + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + exit } } @@ -1608,25 +1646,6 @@ function ScheduledTasks Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -5645,26 +5664,7 @@ function WindowsFeatures Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - - Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC")} | ForEach-Object -Process { + Get-Process | Where-Object -FilterScript {($_.ProcessName -eq "powershell") -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC 2021")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6038,26 +6038,7 @@ function WindowsCapabilities Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { + Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC 2021")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6696,13 +6677,21 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { "Root" { - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # 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) + if ($DriveLetters.Count -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + return + } + + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose + # Desktop Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose @@ -6900,7 +6889,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6940,7 +6939,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -6980,7 +6989,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7020,7 +7039,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7060,7 +7089,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7100,7 +7139,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -9371,7 +9420,7 @@ function InstallDotNetRuntimes param ( [Parameter( - Mandatory = $false, + Mandatory = $true, ParameterSetName = "Runtimes" )] [ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")] @@ -10106,26 +10155,7 @@ function Install-WSL Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { + Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10 LTSC 2021")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -10864,7 +10894,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); } `$ProcessInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo -`$ProcessInfo.FileName = """`$env:SystemRoot\System32\dism.exe""" +`$ProcessInfo.FileName = """`$env:SystemRoot\System32\Dism.exe""" `$ProcessInfo.Arguments = """/Online /English /Cleanup-Image /StartComponentCleanup /NoRestart""" `$ProcessInfo.UseShellExecute = `$true `$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized @@ -12415,58 +12445,57 @@ function WindowsSandbox $Enable ) + if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})) + { + return + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - else + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart + } + else + { + try { - try + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - } - catch [System.Exception] - { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } "Enable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - else + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart + } + else + { + try { - try + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - } - catch [System.Exception] - { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } } @@ -12679,19 +12708,21 @@ function CastToDeviceContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore } } } @@ -12734,19 +12765,21 @@ function ShareContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore } } } @@ -12789,6 +12822,13 @@ function EditWithPaint3DContext $Show ) + if (-not (Get-AppxPackage -Name Microsoft.MSPaint)) + { + return + } + + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + switch ($PSCmdlet.ParameterSetName) { "Hide" @@ -12848,18 +12888,24 @@ function ImagesEditContext $Show ) - if ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed") + if (-not ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed")) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" + if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit)) { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore + New-Item -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Force } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } 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 06d40bfdb..9b833cafb 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10 LTSC 2021" - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -70,7 +70,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.18.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 LTSC 2021 v5.18.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia @@ -886,8 +886,8 @@ ActiveHours -Automatically InstallVCRedist <# - Install the latest .NET Desktop Runtime 6, 7 (x86/x64) - Установить последнюю версию .NET Desktop Runtime 6, 7 (x86/x64) + Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64) + Установить последнюю версию .NET Desktop Runtime 6, 7, 8 (x86/x64) https://dotnet.microsoft.com/en-us/download/dotnet #> 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 1871dea5b..36d6d8f51 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -50,7 +50,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.0 (PowerShell 7) | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.1 (PowerShell 7) | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force 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 a1d4045e5..c0a32a42c 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows-Features OptionalFeaturesTitle = Optionale Features EnableHardwareVT = Virtualisierung in UEFI aktivieren. UserShellFolderNotEmpty = Im Ordner "{0}" befinden sich noch Dateien \nVerschieben Sie sie manuell an einen neuen Ort. +UserFolderLocationMove = Sie sollten den Speicherort des Benutzerordners nicht in das Stammverzeichnis des Laufwerks C ändern. RetrievingDrivesList = Laufwerksliste abrufen... DriveSelect = Wählen Sie das Laufwerk aus, in dessen Stammverzeichnis der Ordner "{0}" erstellt werden soll. CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners "{0}" lautet: "{1}". 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 74c9eedbc..96301eccb 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI. UserShellFolderNotEmpty = Some files left in the "{0}" folder. Move them manually to a new location. +UserFolderLocationMove = You shouldn't change user folder location to C drive root. RetrievingDrivesList = Retrieving drives list... DriveSelect = Select the drive within the root of which the "{0}" folder will be created. CurrentUserFolderLocation = The current "{0}" folder location: "{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 ad579ef1f..673578e3b 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Habilitar la virtualización en UEFI. UserShellFolderNotEmpty = Algunos archivos quedan en la carpeta "{0}". Moverlos manualmente a una nueva ubicación. +UserFolderLocationMove = No deberías cambiar la ubicación de la carpeta de usuario a la raíz de la unidad C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Seleccione la unidad dentro de la raíz de la cual se creó la carpeta "{0}". CurrentUserFolderLocation = La ubicación actual de la carpeta "{0}": "{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 636ecbdf3..3e52ac629 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI. UserShellFolderNotEmpty = Certains fichiers laissés dans le dossier "{0}". Déplacer les manuellement vers un nouvel emplacement. +UserFolderLocationMove = Vous ne devez pas changer l'emplacement du dossier de l'utilisateur pour la racine du lecteur C. RetrievingDrivesList = Récupération de la liste des lecteurs... DriveSelect = Sélectionnez le disque à la racine dans lequel le dossier "{0}" sera créé. CurrentUserFolderLocation = L'emplacement actuel du dossier "{0}": "{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 d7584af6b..105bff7cc 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows szolgáltatások OptionalFeaturesTitle = Opcionális szolgáltatások EnableHardwareVT = Virtualizáció engedélyezése UEFI-ben. UserShellFolderNotEmpty = Néhány fájl maradt a "{0}" könyvtárban. Kérem helyezze át ezeket egy új helyre. +UserFolderLocationMove = Nem szabad megváltoztatni a felhasználói mappa helyét a C meghajtó gyökerére. RetrievingDrivesList = A meghajtók listájának lekérése... DriveSelect = Válassza ki a meghajtó jelét a gyökérkönyvtárban ahol a "{0}" könyvtár létre lesz hozva. CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1}". 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 c0bd516f0..aa171387c 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI. UserShellFolderNotEmpty = Alcuni file rimasti nella cartella "{0}". Spostali manualmente in una nuova posizione. +UserFolderLocationMove = Non si dovrebbe modificare la posizione della cartella utente nella radice dell'unità C. RetrievingDrivesList = Recupero lista unità... DriveSelect = Selezionare l'unità all'interno della radice del quale verrà creato la cartella "{0}" . CurrentUserFolderLocation = La posizione attuale della cartella "{0}": "{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 de64781ad..4414aff17 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Funkcje Windows OptionalFeaturesTitle = Funkcje opcjonalne EnableHardwareVT = Włącz wirtualizację w UEFI. UserShellFolderNotEmpty = Niektóre pliki pozostały w folderze "{0}". Przenieś je ręcznie w nowe miejsce. +UserFolderLocationMove = Nie należy zmieniać lokalizacji folderu użytkownika na katalog główny dysku C. RetrievingDrivesList = Pobieranie listy dysków... DriveSelect = Wybierz dysk w katalogu głównym, w którym zostanie utworzony folder "{0}". CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{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 f17826923..af8908c7c 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI. UserShellFolderNotEmpty = Alguns arquivos deixados na pasta "{0}". Movê-los manualmente para um novo local. +UserFolderLocationMove = Você não deve alterar o local da pasta do usuário para a raiz da unidade C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Selecione a unidade dentro da raiz da qual a pasta "{0}" será criada. CurrentUserFolderLocation = A localização actual da pasta "{0}": "{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 695501b8e..93ba0b119 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI. UserShellFolderNotEmpty = В папке "{0}" остались файлы. Переместите их вручную в новое расположение. +UserFolderLocationMove = Не следует перемещать пользовательские папки в корень диска C. RetrievingDrivesList = Получение списка дисков... DriveSelect = Выберите диск, в корне которого будет создана папка "{0}". CurrentUserFolderLocation = Текущее расположение папки "{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 5f1a32a73..6bf65af02 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Características do Windows OptionalFeaturesTitle = Opsiyonel özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin. UserShellFolderNotEmpty = "{0}" klasöründe bazı dosyalar kaldı. \nKendiniz yeni konuma taşıyın. +UserFolderLocationMove = Kullanıcı klasörü konumunu C sürücüsü kökü olarak değiştirmemelisiniz. RetrievingDrivesList = Sürücü listesi alınıyor... DriveSelect = "{0}" klasörünün oluşturulacağı kök içindeki sürücüyü seçin. CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}". 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 c12c5ff01..2e69edba6 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI. UserShellFolderNotEmpty = У папці "{0}" залишилися файли. Перемістіть їх вручну в нове розташування. +UserFolderLocationMove = Не слід переміщати користувацькі папки в корінь диска C. RetrievingDrivesList = Отримання списку дисків... DriveSelect = Виберіть диск, в корні якого буде створена папка для "{0}". CurrentUserFolderLocation = Поточне розташування папки "{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 0f2dae48b..385b2cb79 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化。 UserShellFolderNotEmpty = 一些文件留在了"{0}"文件夹。请手动将它们移到一个新位置。 +UserFolderLocationMove = 不应将用户文件夹位置更改为 C 盘根目录。 RetrievingDrivesList = 取得驱动器列表..... DriveSelect = 选择将在其根目录中创建"{0}"文件夹的驱动器。 CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}"。 diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1 index e519982a8..11b35b659 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '5.18.0' + ModuleVersion = '5.18.1' GUID = 'aa0b47a7-1770-4b5d-8c9f-cc6c505bcc7a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2024 farag & Inestic. All rights reserved' 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 e6caa7032..0b3342ac5 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 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -115,6 +115,42 @@ public static string GetIndirectString(string indirectString) Add-Type @Signature } + $Signature = @{ + Namespace = "WinAPI" + Name = "ForegroundWindow" + Language = "CSharp" + MemberDefinition = @" +[DllImport("user32.dll")] +public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + +[DllImport("user32.dll")] +[return: MarshalAs(UnmanagedType.Bool)] +public static extern bool SetForegroundWindow(IntPtr hWnd); +"@ + } + + if (-not ("WinAPI.ForegroundWindow" -as [type])) + { + try + { + Add-Type @Signature + } + catch [System.ComponentModel.Win32Exception] + { + Write-Warning -Message $Localization.NonLatinUsernameWarning + + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + + exit + } + } + # Check whether Microsoft Edge as being a system component was removed by harmful tweakers if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")) { @@ -339,6 +375,8 @@ public static string GetIndirectString(string indirectString) # Check whether Get-WindowsEdition cmdlet is working try { + # Import PowerShell 5.1 DISM module + Import-Module -Name DISM -UseWindowsPowerShell Get-WindowsEdition -Online } catch [System.Runtime.InteropServices.COMException] @@ -1722,25 +1760,6 @@ function ScheduledTasks Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6623,25 +6642,6 @@ function WindowsFeatures Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -7016,25 +7016,6 @@ function WindowsCapabilities Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -7674,13 +7655,21 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { "Root" { - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # 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) + if ($DriveLetters.Count -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + return + } + + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose + # Desktop Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose @@ -7878,7 +7867,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7918,7 +7917,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7958,7 +7967,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7998,7 +8017,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -8038,7 +8067,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -8078,7 +8117,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -10506,7 +10555,7 @@ function InstallDotNetRuntimes param ( [Parameter( - Mandatory = $false, + Mandatory = $true, ParameterSetName = "Runtimes" )] [ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")] @@ -11241,25 +11290,6 @@ function Install-WSL Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -12115,25 +12145,6 @@ function UninstallUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -12454,25 +12465,6 @@ function RestoreUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 10")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -13254,7 +13246,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); } `$ProcessInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo -`$ProcessInfo.FileName = """`$env:SystemRoot\System32\dism.exe""" +`$ProcessInfo.FileName = """`$env:SystemRoot\System32\Dism.exe""" `$ProcessInfo.Arguments = """/Online /English /Cleanup-Image /StartComponentCleanup /NoRestart""" `$ProcessInfo.UseShellExecute = `$true `$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized @@ -14805,58 +14797,57 @@ function WindowsSandbox $Enable ) + if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})) + { + return + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - else + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart + } + else + { + try { - try + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - } - catch [System.Exception] - { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } "Enable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - else + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart + } + else + { + try { - try - { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - } - catch [System.Exception] + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } } @@ -15069,19 +15060,21 @@ function CastToDeviceContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore } } } @@ -15124,19 +15117,21 @@ function ShareContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{E2BF9676-5F8F-435C-97EB-11607A5BEDF7}" -Force -ErrorAction Ignore } } } @@ -15179,25 +15174,29 @@ function EditWithPaint3DContext $Show ) - if (Get-AppxPackage -Name Microsoft.MSPaint) + if (-not (Get-AppxPackage -Name Microsoft.MSPaint)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + foreach ($Extension in $Extensions) { - $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") - foreach ($Extension in $Extensions) - { - New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } + New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force } - "Show" + } + "Show" + { + $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") + foreach ($Extension in $Extensions) { - $Extensions = @(".bmp", ".gif", ".jpe", ".jpeg", ".jpg", ".png", ".tif", ".tiff") - foreach ($Extension in $Extensions) - { - Remove-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore - } + Remove-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\$Extension\Shell\3D Edit" -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } @@ -15241,18 +15240,20 @@ function EditWithPhotosContext $Show ) - if (Get-AppxPackage -Name Microsoft.Windows.Photos) + if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" - { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore - } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } @@ -15295,18 +15296,20 @@ function CreateANewVideoContext $Show ) - if (Get-AppxPackage -Name Microsoft.Windows.Photos) + if (-not (Get-AppxPackage -Name Microsoft.Windows.Photos)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" - { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore - } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } @@ -15349,18 +15352,24 @@ function ImagesEditContext $Show ) - if ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed") + if (-not ((Get-WindowsCapability -Online -Name "Microsoft.Windows.MSPaint*").State -eq "Installed")) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force - } - "Show" + if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit)) { - Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore + New-Item -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Force } + New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\edit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore } } } 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 9d844c97f..1c03e4c98 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 10 (PowerShell 7)" - Version: v5.18.0 - Date: 02.02.2024 + Version: v5.18.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -70,7 +70,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.0 (PowerShell 7) | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 10 v5.18.1 (PowerShell 7) | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" # PowerShell 7 doesn't load en-us localization automatically if there is no localization folder in user's language which is determined by $PSUICulture # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-localizeddata?view=powershell-7.3 @@ -1016,8 +1016,8 @@ UninstallPCHealthCheck InstallVCRedist <# - Install the latest .NET Desktop Runtime 6, 7 (x86/x64) - Установить последнюю версию .NET Desktop Runtime 6, 7 (x86/x64) + Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64) + Установить последнюю версию .NET Desktop Runtime 6, 7, 8 (x86/x64) https://dotnet.microsoft.com/en-us/download/dotnet #> diff --git a/src/Sophia_Script_for_Windows_11/Functions.ps1 b/src/Sophia_Script_for_Windows_11/Functions.ps1 index 033258407..600c44c31 100644 --- a/src/Sophia_Script_for_Windows_11/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_11/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v6.6.0 - Date: 02.02.2024 + Version: v6.6.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -50,7 +50,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force 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 203e609cf..ced4df6b4 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows-Features OptionalFeaturesTitle = Optionale Features EnableHardwareVT = Virtualisierung in UEFI aktivieren. UserShellFolderNotEmpty = Im Ordner "{0}" befinden sich noch Dateien \nVerschieben Sie sie manuell an einen neuen Ort. +UserFolderLocationMove = Sie sollten den Speicherort des Benutzerordners nicht in das Stammverzeichnis des Laufwerks C ändern. RetrievingDrivesList = Laufwerksliste abrufen... DriveSelect = Wählen Sie das Laufwerk aus, in dessen Stammverzeichnis der Ordner "{0}" erstellt werden soll. CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners "{0}" lautet: "{1}". 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 428f95a41..555027bc6 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI. UserShellFolderNotEmpty = Some files left in the "{0}" folder. Move them manually to a new location. +UserFolderLocationMove = You shouldn't change user folder location to C drive root. RetrievingDrivesList = Retrieving drives list... DriveSelect = Select the drive within the root of which the "{0}" folder will be created. CurrentUserFolderLocation = The current "{0}" folder location: "{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 c13135838..934cf3712 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Habilitar la virtualización en UEFI. UserShellFolderNotEmpty = Algunos archivos quedan en la carpeta "{0}". Moverlos manualmente a una nueva ubicación. +UserFolderLocationMove = No deberías cambiar la ubicación de la carpeta de usuario a la raíz de la unidad C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Seleccione la unidad dentro de la raíz de la cual se creó la carpeta "{0}". CurrentUserFolderLocation = La ubicación actual de la carpeta "{0}": "{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 3ccae0bb2..d10fa910e 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI. UserShellFolderNotEmpty = Certains fichiers laissés dans le dossier "{0}". Déplacer les manuellement vers un nouvel emplacement. +UserFolderLocationMove = Vous ne devez pas changer l'emplacement du dossier de l'utilisateur pour la racine du lecteur C. RetrievingDrivesList = Récupération de la liste des lecteurs... DriveSelect = Sélectionnez le disque à la racine dans lequel le dossier "{0}" sera créé. CurrentUserFolderLocation = L'emplacement actuel du dossier "{0}": "{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 f4517dbeb..6bd5b9bde 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows szolgáltatások OptionalFeaturesTitle = Opcionális szolgáltatások EnableHardwareVT = Virtualizáció engedélyezése UEFI-ben. UserShellFolderNotEmpty = Néhány fájl maradt a "{0}" könyvtárban. Kérem helyezze át ezeket egy új helyre. +UserFolderLocationMove = Nem szabad megváltoztatni a felhasználói mappa helyét a C meghajtó gyökerére. RetrievingDrivesList = A meghajtók listájának lekérése... DriveSelect = Válassza ki a meghajtó jelét a gyökérkönyvtárban ahol a "{0}" könyvtár létre lesz hozva. CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1}". 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 3cd20cfd9..3020443d5 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI. UserShellFolderNotEmpty = Alcuni file rimasti nella cartella "{0}". Spostali manualmente in una nuova posizione. +UserFolderLocationMove = Non si dovrebbe modificare la posizione della cartella utente nella radice dell'unità C. RetrievingDrivesList = Recupero lista unità... DriveSelect = Selezionare l'unità all'interno della radice del quale verrà creato la cartella "{0}" . CurrentUserFolderLocation = La posizione attuale della cartella "{0}": "{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 69b18cd5d..5882037ff 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Funkcje Windows OptionalFeaturesTitle = Funkcje opcjonalne EnableHardwareVT = Włącz wirtualizację w UEFI. UserShellFolderNotEmpty = Niektóre pliki pozostały w folderze "{0}". Przenieś je ręcznie w nowe miejsce. +UserFolderLocationMove = Nie należy zmieniać lokalizacji folderu użytkownika na katalog główny dysku C. RetrievingDrivesList = Pobieranie listy dysków... DriveSelect = Wybierz dysk w katalogu głównym, w którym zostanie utworzony folder "{0}". CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{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 6c11bc1ad..e0042935f 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI. UserShellFolderNotEmpty = Alguns arquivos deixados na pasta "{0}". Movê-los manualmente para um novo local. +UserFolderLocationMove = Você não deve alterar o local da pasta do usuário para a raiz da unidade C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Selecione a unidade dentro da raiz da qual a pasta "{0}" será criada. CurrentUserFolderLocation = A localização actual da pasta "{0}": "{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 c608e2fcc..54929db30 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI. UserShellFolderNotEmpty = В папке "{0}" остались файлы. Переместите их вручную в новое расположение. +UserFolderLocationMove = Не следует перемещать пользовательские папки в корень диска C. RetrievingDrivesList = Получение списка дисков... DriveSelect = Выберите диск, в корне которого будет создана папка "{0}". CurrentUserFolderLocation = Текущее расположение папки "{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 57b66a511..00c2c7e10 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Características do Windows OptionalFeaturesTitle = Opsiyonel özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin. UserShellFolderNotEmpty = "{0}" klasöründe bazı dosyalar kaldı. \nKendiniz yeni konuma taşıyın. +UserFolderLocationMove = Kullanıcı klasörü konumunu C sürücüsü kökü olarak değiştirmemelisiniz. RetrievingDrivesList = Sürücü listesi alınıyor... DriveSelect = "{0}" klasörünün oluşturulacağı kök içindeki sürücüyü seçin. CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}". 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 45833a2fc..62620eaac 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI. UserShellFolderNotEmpty = У папці "{0}" залишилися файли. Перемістіть їх вручну в нове розташування. +UserFolderLocationMove = Не слід переміщати користувацькі папки в корінь диска C. RetrievingDrivesList = Отримання списку дисків... DriveSelect = Виберіть диск, в корні якого буде створена папка для "{0}". CurrentUserFolderLocation = Поточне розташування папки "{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 b9bb6ef79..7f69a98b8 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 @@ -27,6 +27,7 @@ WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化。 UserShellFolderNotEmpty = 一些文件留在了"{0}"文件夹。请手动将它们移到一个新位置。 +UserFolderLocationMove = 不应将用户文件夹位置更改为 C 盘根目录。 RetrievingDrivesList = 取得驱动器列表..... DriveSelect = 选择将在其根目录中创建"{0}"文件夹的驱动器。 CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}"。 diff --git a/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1 index bfd2878fb..6147bd6b2 100644 --- a/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '6.6.0' + ModuleVersion = '6.6.1' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2024 farag & Inestic. All rights reserved' diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 2b8b97b0e..0c8a22983 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v6.6.0 - Date: 02.02.2024 + Version: v6.6.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -129,6 +129,44 @@ public static string GetIndirectString(string indirectString) Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + + exit + } + } + + $Signature = @{ + Namespace = "WinAPI" + Name = "ForegroundWindow" + Language = "CSharp" + MemberDefinition = @" +[DllImport("user32.dll")] +public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + +[DllImport("user32.dll")] +[return: MarshalAs(UnmanagedType.Bool)] +public static extern bool SetForegroundWindow(IntPtr hWnd); +"@ + } + + if (-not ("WinAPI.ForegroundWindow" -as [type])) + { + try + { + Add-Type @Signature + } + catch [System.ComponentModel.Win32Exception] + { + Write-Warning -Message $Localization.NonLatinUsernameWarning + + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + exit } } @@ -1715,25 +1753,6 @@ function ScheduledTasks Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6022,25 +6041,6 @@ function WindowsFeatures Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6412,25 +6412,6 @@ function WindowsCapabilities Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -7274,13 +7255,21 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { "Root" { - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # 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) + if ($DriveLetters.Count -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + return + } + + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose + # Desktop Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose @@ -7478,7 +7467,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7518,7 +7517,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7558,7 +7567,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7598,7 +7617,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7638,7 +7667,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7678,7 +7717,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -9931,7 +9980,7 @@ function InstallDotNetRuntimes param ( [Parameter( - Mandatory = $false, + Mandatory = $true, ParameterSetName = "Runtimes" )] [ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")] @@ -10750,25 +10799,6 @@ function Install-WSL Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -11405,25 +11435,6 @@ function UninstallUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -11734,25 +11745,6 @@ function RestoreUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -12367,7 +12359,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); } `$ProcessInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo -`$ProcessInfo.FileName = """`$env:SystemRoot\System32\dism.exe""" +`$ProcessInfo.FileName = """`$env:SystemRoot\System32\Dism.exe""" `$ProcessInfo.Arguments = """/Online /English /Cleanup-Image /StartComponentCleanup /NoRestart""" `$ProcessInfo.UseShellExecute = `$true `$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized @@ -13861,58 +13853,57 @@ function WindowsSandbox $Enable ) + if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})) + { + return + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - else + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart + } + else + { + try { - try - { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - } - catch [System.Exception] + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } "Enable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - else + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart + } + else + { + try { - try - { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - } - catch [System.Exception] + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } } @@ -14375,19 +14366,21 @@ function CastToDeviceContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore } } } @@ -14485,22 +14478,26 @@ function EditWithClipchampContext $Show ) - if (Get-AppxPackage -Name Clipchamp.Clipchamp) + if (-not (Get-AppxPackage -Name Clipchamp.Clipchamp)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -Force -ErrorAction Ignore + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) - { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force - } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -PropertyType String -Value "Play to menu" -Force - } - "Show" + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -Force -ErrorAction Ignore + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -Force -ErrorAction Ignore } } } @@ -14863,22 +14860,26 @@ function OpenWindowsTerminalContext $Hide ) - if (Get-AppxPackage -Name Microsoft.WindowsTerminal) + if (-not (Get-AppxPackage -Name Microsoft.WindowsTerminal)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -Force -ErrorAction Ignore + + switch ($PSCmdlet.ParameterSetName) + { + "Show" { - "Show" - { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -Force -ErrorAction Ignore - } - "Hide" + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -Force -ErrorAction Ignore + } + "Hide" + { + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) - { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force - } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -PropertyType String -Value "WindowsTerminal" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -PropertyType String -Value "" -Force } } } @@ -14921,68 +14922,65 @@ function OpenWindowsTerminalAdminContext $Disable ) - # Check whether it is not blocked by policy - $BlockGUID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore) - # Check whether the package installed - $TerminalInstalled = (Get-AppxPackage -Name Microsoft.WindowsTerminal) - # Check whether Windows Terminal version is greater or equal than 1.11 - $TerminalInstalledVersion = ([System.Version](Get-AppxPackage -Name Microsoft.WindowsTerminal).Version -ge [System.Version]"1.11") - if ((-not $BlockGUID) -and $TerminalInstalled -and $TerminalInstalledVersion) + if (-not (Get-AppxPackage -Name Microsoft.WindowsTerminal)) { - if (-not (Test-Path -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json")) - { - Start-Process -FilePath wt -PassThru - Start-Sleep -Seconds 2 - Stop-Process -Name WindowsTerminal -Force -PassThru - } + return + } - try - { - Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force | ConvertFrom-Json - } - catch [System.ArgumentException] - { - Write-Error -Message ($Global:Error.Exception.Message | Select-Object -First 1) -ErrorAction SilentlyContinue + if (-not (Test-Path -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json")) + { + Start-Process -FilePath wt -PassThru + Start-Sleep -Seconds 2 + Stop-Process -Name WindowsTerminal -Force -PassThru + } + + try + { + $Terminal = Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force | ConvertFrom-Json + } + catch [System.ArgumentException] + { + Write-Error -Message ($Global:Error.Exception.Message | Select-Object -First 1) -ErrorAction SilentlyContinue - Invoke-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState" + Invoke-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState" - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.Skipped -Verbose + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose - return - } + return + } - $Terminal = Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force | ConvertFrom-Json + switch ($PSCmdlet.ParameterSetName) + { + "Enable" + { + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore - switch ($PSCmdlet.ParameterSetName) + if ($Terminal.profiles.defaults.elevate) + { + $Terminal.profiles.defaults.elevate = $true + } + else + { + $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $true -Force + } + } + "Disable" { - "Enable" + if ($Terminal.profiles.defaults.elevate) { - if ($Terminal.profiles.defaults.elevate) - { - $Terminal.profiles.defaults.elevate = $true - } - else - { - $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $true -Force - } + $Terminal.profiles.defaults.elevate = $false } - "Disable" + else { - if ($Terminal.profiles.defaults.elevate) - { - $Terminal.profiles.defaults.elevate = $false - } - else - { - $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $false -Force - } + $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $false -Force } } - - # Save in UTF-8 with BOM despite JSON must not has the BOM: https://datatracker.ietf.org/doc/html/rfc8259#section-8.1. Unless Terminal profile names which contains non-Latin characters will have "?" instead of titles - ConvertTo-Json -InputObject $Terminal -Depth 4 | Set-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force } + + # Save in UTF-8 with BOM despite JSON must not has the BOM: https://datatracker.ietf.org/doc/html/rfc8259#section-8.1. Unless Terminal profile names which contains non-Latin characters will have "?" instead of titles + ConvertTo-Json -InputObject $Terminal -Depth 4 | Set-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force } <# diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1 index 0ce8e69a0..41009bba7 100644 --- a/src/Sophia_Script_for_Windows_11/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 11" - Version: v6.6.0 - Date: 02.02.2024 + Version: v6.6.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -69,7 +69,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-LocalizedData -BindingVariable Global:Localization -BaseDirectory $PSScriptRoot\Localizations -FileName Sophia 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 b70a4fd1e..223792f78 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS The TAB completion for functions and their arguments - Version: v6.6.0 - Date: 02.02.2024 + Version: v6.6.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -50,7 +50,7 @@ function Sophia Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.0 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.1 | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\Sophia.psd1 -PassThru -Force 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 1a2798ebb..99c2e103c 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Windows-Features OptionalFeaturesTitle = Optionale Features EnableHardwareVT = Virtualisierung in UEFI aktivieren. UserShellFolderNotEmpty = Im Ordner "{0}" befinden sich noch Dateien \nVerschieben Sie sie manuell an einen neuen Ort. +UserFolderLocationMove = Sie sollten den Speicherort des Benutzerordners nicht in das Stammverzeichnis des Laufwerks C ändern. RetrievingDrivesList = Laufwerksliste abrufen... DriveSelect = Wählen Sie das Laufwerk aus, in dessen Stammverzeichnis der Ordner "{0}" erstellt werden soll. CurrentUserFolderLocation = Der aktuelle Speicherort des Ordners "{0}" lautet: "{1}". 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 9a9e66fe6..f134a4a9b 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Windows features OptionalFeaturesTitle = Optional features EnableHardwareVT = Enable Virtualization in UEFI. UserShellFolderNotEmpty = Some files left in the "{0}" folder. Move them manually to a new location. +UserFolderLocationMove = You shouldn't change user folder location to C drive root. RetrievingDrivesList = Retrieving drives list... DriveSelect = Select the drive within the root of which the "{0}" folder will be created. CurrentUserFolderLocation = The current "{0}" folder location: "{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 9f8e8f221..ea00cdaff 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Características de Windows OptionalFeaturesTitle = Características opcionales EnableHardwareVT = Habilitar la virtualización en UEFI. UserShellFolderNotEmpty = Algunos archivos quedan en la carpeta "{0}". Moverlos manualmente a una nueva ubicación. +UserFolderLocationMove = No deberías cambiar la ubicación de la carpeta de usuario a la raíz de la unidad C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Seleccione la unidad dentro de la raíz de la cual se creó la carpeta "{0}". CurrentUserFolderLocation = La ubicación actual de la carpeta "{0}": "{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 96e57c9e2..be68c3306 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Fonctionnalités OptionalFeaturesTitle = Fonctionnalités optionnelles EnableHardwareVT = Activer la virtualisation dans UEFI. UserShellFolderNotEmpty = Certains fichiers laissés dans le dossier "{0}". Déplacer les manuellement vers un nouvel emplacement. +UserFolderLocationMove = Vous ne devez pas changer l'emplacement du dossier de l'utilisateur pour la racine du lecteur C. RetrievingDrivesList = Récupération de la liste des lecteurs... DriveSelect = Sélectionnez le disque à la racine dans lequel le dossier "{0}" sera créé. CurrentUserFolderLocation = L'emplacement actuel du dossier "{0}": "{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 791c21646..a5994afff 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Windows szolgáltatások OptionalFeaturesTitle = Opcionális szolgáltatások EnableHardwareVT = Virtualizáció engedélyezése UEFI-ben. UserShellFolderNotEmpty = Néhány fájl maradt a "{0}" könyvtárban. Kérem helyezze át ezeket egy új helyre. +UserFolderLocationMove = Nem szabad megváltoztatni a felhasználói mappa helyét a C meghajtó gyökerére. RetrievingDrivesList = A meghajtók listájának lekérése... DriveSelect = Válassza ki a meghajtó jelét a gyökérkönyvtárban ahol a "{0}" könyvtár létre lesz hozva. CurrentUserFolderLocation = Az aktuális "{0}" mappa helye: "{1}". 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 8dd49a447..937211495 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Funzionalità di Windows OptionalFeaturesTitle = Caratteristiche opzionali EnableHardwareVT = Abilita virtualizzazione in UEFI. UserShellFolderNotEmpty = Alcuni file rimasti nella cartella "{0}". Spostali manualmente in una nuova posizione. +UserFolderLocationMove = Non si dovrebbe modificare la posizione della cartella utente nella radice dell'unità C. RetrievingDrivesList = Recupero lista unità... DriveSelect = Selezionare l'unità all'interno della radice del quale verrà creato la cartella "{0}" . CurrentUserFolderLocation = La posizione attuale della cartella "{0}": "{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 9a68963ee..2cac66bab 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Funkcje Windows OptionalFeaturesTitle = Funkcje opcjonalne EnableHardwareVT = Włącz wirtualizację w UEFI. UserShellFolderNotEmpty = Niektóre pliki pozostały w folderze "{0}". Przenieś je ręcznie w nowe miejsce. +UserFolderLocationMove = Nie należy zmieniać lokalizacji folderu użytkownika na katalog główny dysku C. RetrievingDrivesList = Pobieranie listy dysków... DriveSelect = Wybierz dysk w katalogu głównym, w którym zostanie utworzony folder "{0}". CurrentUserFolderLocation = Lokalizacja folderu "{0}": "{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 4e708ee3d..c8d4a6108 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Recursos do Windows OptionalFeaturesTitle = Recursos opcionais EnableHardwareVT = Habilitar virtualização em UEFI. UserShellFolderNotEmpty = Alguns arquivos deixados na pasta "{0}". Movê-los manualmente para um novo local. +UserFolderLocationMove = Você não deve alterar o local da pasta do usuário para a raiz da unidade C. RetrievingDrivesList = Recuperando lista de unidades... DriveSelect = Selecione a unidade dentro da raiz da qual a pasta "{0}" será criada. CurrentUserFolderLocation = A localização actual da pasta "{0}": "{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 f815c2fa6..0a18dbb14 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Компоненты Windows OptionalFeaturesTitle = Дополнительные компоненты EnableHardwareVT = Включите виртуализацию в UEFI. UserShellFolderNotEmpty = В папке "{0}" остались файлы. Переместите их вручную в новое расположение. +UserFolderLocationMove = Не следует перемещать пользовательские папки в корень диска C. RetrievingDrivesList = Получение списка дисков... DriveSelect = Выберите диск, в корне которого будет создана папка "{0}". CurrentUserFolderLocation = Текущее расположение папки "{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 3447b6bfb..83147bf7d 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Características do Windows OptionalFeaturesTitle = Opsiyonel özellikler EnableHardwareVT = UEFI'dan sanallaştırmayı aktifleştirin. UserShellFolderNotEmpty = "{0}" klasöründe bazı dosyalar kaldı. \nKendiniz yeni konuma taşıyın. +UserFolderLocationMove = Kullanıcı klasörü konumunu C sürücüsü kökü olarak değiştirmemelisiniz. RetrievingDrivesList = Sürücü listesi alınıyor... DriveSelect = "{0}" klasörünün oluşturulacağı kök içindeki sürücüyü seçin. CurrentUserFolderLocation = Geçerli "{0}" klasör konumu: "{1}". 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 896c765d6..af41d0b85 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Компоненти Windows OptionalFeaturesTitle = Додаткові компоненти EnableHardwareVT = Увімкніть віртуалізацію в UEFI. UserShellFolderNotEmpty = У папці "{0}" залишилися файли. Перемістіть їх вручну в нове розташування. +UserFolderLocationMove = Не слід переміщати користувацькі папки в корінь диска C. RetrievingDrivesList = Отримання списку дисків... DriveSelect = Виберіть диск, в корні якого буде створена папка для "{0}". CurrentUserFolderLocation = Поточне розташування папки "{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 988c32f04..ea424cf7f 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 @@ -26,6 +26,7 @@ WindowsFeaturesTitle = Windows功能 OptionalFeaturesTitle = 可选功能 EnableHardwareVT = UEFI中开启虚拟化。 UserShellFolderNotEmpty = 一些文件留在了"{0}"文件夹。请手动将它们移到一个新位置。 +UserFolderLocationMove = 不应将用户文件夹位置更改为 C 盘根目录。 RetrievingDrivesList = 取得驱动器列表..... DriveSelect = 选择将在其根目录中创建"{0}"文件夹的驱动器。 CurrentUserFolderLocation = 当前"{0}"文件夹的位置:"{1}"。 diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1 index 997bd5647..5a4ab1365 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '..\Module\Sophia.psm1' - ModuleVersion = '6.6.0' + ModuleVersion = '6.6.1' GUID = '109cc881-c42b-45af-a74a-550781989d6a' Author = 'Dmitry "farag" Nefedov' Copyright = '(c) 2014—2024 farag & Inestic. All rights reserved' 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 64af6f32d..602ca0a8e 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 @@ -2,8 +2,8 @@ .SYNOPSIS Sophia Script is a PowerShell module for Windows 10 & Windows 11 fine-tuning and automating the routine tasks - Version: v6.6.0 - Date: 02.02.2024 + Version: v6.6.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -114,6 +114,42 @@ public static string GetIndirectString(string indirectString) Add-Type @Signature } + $Signature = @{ + Namespace = "WinAPI" + Name = "ForegroundWindow" + Language = "CSharp" + MemberDefinition = @" +[DllImport("user32.dll")] +public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + +[DllImport("user32.dll")] +[return: MarshalAs(UnmanagedType.Bool)] +public static extern bool SetForegroundWindow(IntPtr hWnd); +"@ + } + + if (-not ("WinAPI.ForegroundWindow" -as [type])) + { + try + { + Add-Type @Signature + } + catch [System.ComponentModel.Win32Exception] + { + Write-Warning -Message $Localization.NonLatinUsernameWarning + + Start-Process -FilePath "https://t.me/sophia_chat" + Start-Process -FilePath "https://discord.gg/sSryhaEv79" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/releases/latest" + Start-Process -FilePath "https://github.com/farag2/Sophia-Script-for-Windows/releases/latest" + + Start-Process -FilePath "https://github.com/PowerShell/PowerShell/issues/21070" + + exit + } + } + # Check whether Microsoft Edge as being a system component was removed by harmful tweakers if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")) { @@ -327,6 +363,8 @@ public static string GetIndirectString(string indirectString) # Check whether Get-WindowsEdition cmdlet is working try { + # Import PowerShell 5.1 DISM module + Import-Module -Name DISM -UseWindowsPowerShell Get-WindowsEdition -Online } catch [System.Runtime.InteropServices.COMException] @@ -1701,25 +1739,6 @@ function ScheduledTasks Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6008,25 +6027,6 @@ function WindowsFeatures Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -6398,25 +6398,6 @@ function WindowsCapabilities Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -7260,13 +7241,21 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int { "Root" { - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose - # 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) + if ($DriveLetters.Count -eq 1) + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + return + } + + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.RetrievingDrivesList -Verbose + # Desktop Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message ($Localization.DriveSelect -f [WinAPI.GetStrings]::GetString(21769)) -Verbose @@ -7464,7 +7453,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Desktop -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7504,7 +7503,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Documents -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7544,7 +7553,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Downloads -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7584,7 +7603,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Music -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7624,7 +7653,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Pictures -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -7664,7 +7703,17 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int if ($FolderBrowserDialog.SelectedPath) { - Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + if ($FolderBrowserDialog.SelectedPath -eq "C:\") + { + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.UserFolderLocationMove -Verbose + + continue + } + else + { + Set-UserShellFolder -UserFolder Videos -FolderPath $FolderBrowserDialog.SelectedPath + } } } $Skip @@ -9917,7 +9966,7 @@ function InstallDotNetRuntimes param ( [Parameter( - Mandatory = $false, + Mandatory = $true, ParameterSetName = "Runtimes" )] [ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")] @@ -10736,25 +10785,6 @@ function Install-WSL Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -11401,25 +11431,6 @@ function UninstallUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -11740,25 +11751,6 @@ function RestoreUWPApps Add-Type -AssemblyName System.Windows.Forms - $Signature = @{ - Namespace = "WinAPI" - Name = "ForegroundWindow" - Language = "CSharp" - MemberDefinition = @" -[DllImport("user32.dll")] -public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - -[DllImport("user32.dll")] -[return: MarshalAs(UnmanagedType.Bool)] -public static extern bool SetForegroundWindow(IntPtr hWnd); -"@ - } - - if (-not ("WinAPI.ForegroundWindow" -as [type])) - { - Add-Type @Signature - } - Get-Process | Where-Object -FilterScript {(($_.ProcessName -eq "powershell") -or ($_.ProcessName -eq "WindowsTerminal")) -and ($_.MainWindowTitle -match "Sophia Script for Windows 11")} | ForEach-Object -Process { # Show window, if minimized [WinAPI.ForegroundWindow]::ShowWindowAsync($_.MainWindowHandle, 10) @@ -12373,7 +12365,7 @@ public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); } `$ProcessInfo = New-Object -TypeName System.Diagnostics.ProcessStartInfo -`$ProcessInfo.FileName = """`$env:SystemRoot\System32\dism.exe""" +`$ProcessInfo.FileName = """`$env:SystemRoot\System32\Dism.exe""" `$ProcessInfo.Arguments = """/Online /English /Cleanup-Image /StartComponentCleanup /NoRestart""" `$ProcessInfo.UseShellExecute = `$true `$ProcessInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Minimized @@ -13867,58 +13859,57 @@ function WindowsSandbox $Enable ) + if (-not (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})) + { + return + } + switch ($PSCmdlet.ParameterSetName) { "Disable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - else + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart + } + else + { + try { - try - { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart - } - } - catch [System.Exception] + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } "Enable" { - if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")}) + # Checking whether x86 virtualization is enabled in the firmware + if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) { - # Checking whether x86 virtualization is enabled in the firmware - if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - else + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart + } + else + { + try { - try - { - # Determining whether Hyper-V is enabled - if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) - { - Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart - } - } - catch [System.Exception] + # Determining whether Hyper-V is enabled + if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent) { - Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart } } + catch [System.Exception] + { + Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue + } } } } @@ -14381,19 +14372,21 @@ function CastToDeviceContext $Show ) + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + switch ($PSCmdlet.ParameterSetName) { "Hide" { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "" -Force } "Show" { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore } } } @@ -14491,22 +14484,26 @@ function EditWithClipchampContext $Show ) - if (Get-AppxPackage -Name Clipchamp.Clipchamp) + if (-not (Get-AppxPackage -Name Clipchamp.Clipchamp)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -Force -ErrorAction Ignore + + switch ($PSCmdlet.ParameterSetName) + { + "Hide" { - "Hide" - { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) - { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force - } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -PropertyType String -Value "Play to menu" -Force - } - "Show" + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -Force -ErrorAction Ignore + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -PropertyType String -Value "" -Force + } + "Show" + { + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{8AB635F8-9A67-4698-AB99-784AD929F3B4}" -Force -ErrorAction Ignore } } } @@ -14869,22 +14866,24 @@ function OpenWindowsTerminalContext $Hide ) - if (Get-AppxPackage -Name Microsoft.WindowsTerminal) + if (-not (Get-AppxPackage -Name Microsoft.WindowsTerminal)) { - switch ($PSCmdlet.ParameterSetName) + return + } + + switch ($PSCmdlet.ParameterSetName) + { + "Show" { - "Show" - { - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -Force -ErrorAction Ignore - } - "Hide" + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -Force -ErrorAction Ignore + } + "Hide" + { + if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) { - if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked")) - { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force - } - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -PropertyType String -Value "WindowsTerminal" -Force + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force } + New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -PropertyType String -Value "" -Force } } } @@ -14927,68 +14926,65 @@ function OpenWindowsTerminalAdminContext $Disable ) - # Check whether it is not blocked by policy - $BlockGUID = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore) - # Check whether the package installed - $TerminalInstalled = (Get-AppxPackage -Name Microsoft.WindowsTerminal) - # Check whether Windows Terminal version is greater or equal than 1.11 - $TerminalInstalledVersion = ([System.Version](Get-AppxPackage -Name Microsoft.WindowsTerminal).Version -ge [System.Version]"1.11") - if ((-not $BlockGUID) -and $TerminalInstalled -and $TerminalInstalledVersion) + if (-not (Get-AppxPackage -Name Microsoft.WindowsTerminal)) { - if (-not (Test-Path -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json")) - { - Start-Process -FilePath wt -PassThru - Start-Sleep -Seconds 2 - Stop-Process -Name WindowsTerminal -Force -PassThru - } + return + } - try - { - Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Raw | Test-Json -ErrorAction Stop - } - catch [System.Exception] - { - Write-Error -Message ($Global:Error.Exception.Message | Select-Object -First 1) -ErrorAction SilentlyContinue + if (-not (Test-Path -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json")) + { + Start-Process -FilePath wt -PassThru + Start-Sleep -Seconds 2 + Stop-Process -Name WindowsTerminal -Force -PassThru + } - Invoke-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState" + try + { + $Terminal = Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force | ConvertFrom-Json + } + catch [System.ArgumentException] + { + Write-Error -Message ($Global:Error.Exception.Message | Select-Object -First 1) -ErrorAction SilentlyContinue - Write-Information -MessageData "" -InformationAction Continue - Write-Verbose -Message $Localization.Skipped -Verbose + Invoke-Item -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState" - return - } + Write-Information -MessageData "" -InformationAction Continue + Write-Verbose -Message $Localization.Skipped -Verbose - $Terminal = Get-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding utf8 -Force | ConvertFrom-Json + return + } - switch ($PSCmdlet.ParameterSetName) + switch ($PSCmdlet.ParameterSetName) + { + "Enable" { - "Enable" + Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -ErrorAction Ignore + + if ($Terminal.profiles.defaults.elevate) { - if ($Terminal.profiles.defaults.elevate) - { - $Terminal.profiles.defaults.elevate = $true - } - else - { - $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $true -Force - } + $Terminal.profiles.defaults.elevate = $true } - "Disable" + else { - if ($Terminal.profiles.defaults.elevate) - { - $Terminal.profiles.defaults.elevate = $false - } - else - { - $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $false -Force - } + $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $true -Force + } + } + "Disable" + { + if ($Terminal.profiles.defaults.elevate) + { + $Terminal.profiles.defaults.elevate = $false + } + else + { + $Terminal.profiles.defaults | Add-Member -MemberType NoteProperty -Name elevate -Value $false -Force } } - - # Save in UTF-8 with BOM despite JSON must not has the BOM: https://datatracker.ietf.org/doc/html/rfc8259#section-8.1. Unless Terminal profile names which contains non-Latin characters will have "?" instead of titles - ConvertTo-Json -InputObject $Terminal -Depth 4 | Set-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding utf8 -Force } + + # Save in UTF-8 with BOM despite JSON must not has the BOM: https://datatracker.ietf.org/doc/html/rfc8259#section-8.1. Unless Terminal profile names which contains non-Latin characters will have "?" instead of titles + ConvertTo-Json -InputObject $Terminal -Depth 4 | Set-Content -Path "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -Encoding UTF8 -Force } <# 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 bae093f7f..d80102309 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 @@ -2,8 +2,8 @@ .SYNOPSIS Default preset file for "Sophia Script for Windows 11 (PowerShell 7)" - Version: v6.6.0 - Date: 02.02.2024 + Version: v6.6.1 + Date: 03.03.2024 Copyright (c) 2014—2024 farag Copyright (c) 2019—2024 farag & Inestic @@ -69,7 +69,7 @@ param Clear-Host -$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.0 (PowerShell 7) | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" +$Host.UI.RawUI.WindowTitle = "Sophia Script for Windows 11 v6.6.1 (PowerShell 7) | Made with $([System.Char]::ConvertFromUtf32(0x1F497)) of Windows | $([System.Char]0x00A9) farag & Inestic, 2014$([System.Char]0x2013)2024" Remove-Module -Name Sophia -Force -ErrorAction Ignore @@ -990,8 +990,8 @@ DefaultTerminalApp -WindowsTerminal InstallVCRedist <# - Install the latest .NET Desktop Runtime 6, 7 (x86/x64) - Установить последнюю версию .NET Desktop Runtime 6, 7 (x86/x64) + Install the latest .NET Desktop Runtime 6, 7, 8 (x86/x64) + Установить последнюю версию .NET Desktop Runtime 6, 7, 8 (x86/x64) https://dotnet.microsoft.com/en-us/download/dotnet #>