Browse Source

Code refactoring

master
Dmitry Nefedov 8 months ago
parent
commit
ba0e865263
  1. BIN
      Wrapper/SophiaScriptWrapper.exe
  2. 14
      sophia_script_versions.json
  3. 6
      src/Sophia_Script_for_Windows_10/Functions.ps1
  4. 1
      src/Sophia_Script_for_Windows_10/Localizations/de-DE/Sophia.psd1
  5. 1
      src/Sophia_Script_for_Windows_10/Localizations/en-US/Sophia.psd1
  6. 1
      src/Sophia_Script_for_Windows_10/Localizations/es-ES/Sophia.psd1
  7. 1
      src/Sophia_Script_for_Windows_10/Localizations/fr-FR/Sophia.psd1
  8. 1
      src/Sophia_Script_for_Windows_10/Localizations/hu-HU/Sophia.psd1
  9. 1
      src/Sophia_Script_for_Windows_10/Localizations/it-IT/Sophia.psd1
  10. 1
      src/Sophia_Script_for_Windows_10/Localizations/pl-PL/Sophia.psd1
  11. 1
      src/Sophia_Script_for_Windows_10/Localizations/pt-BR/Sophia.psd1
  12. 1
      src/Sophia_Script_for_Windows_10/Localizations/ru-RU/Sophia.psd1
  13. 1
      src/Sophia_Script_for_Windows_10/Localizations/tr-TR/Sophia.psd1
  14. 1
      src/Sophia_Script_for_Windows_10/Localizations/uk-UA/Sophia.psd1
  15. 1
      src/Sophia_Script_for_Windows_10/Localizations/zh-CN/Sophia.psd1
  16. 2
      src/Sophia_Script_for_Windows_10/Manifest/Sophia.psd1
  17. 431
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  18. 10
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  19. 6
      src/Sophia_Script_for_Windows_10_LTSC_2019/Functions.ps1
  20. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/de-DE/Sophia.psd1
  21. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/en-US/Sophia.psd1
  22. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/es-ES/Sophia.psd1
  23. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/fr-FR/Sophia.psd1
  24. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/hu-HU/Sophia.psd1
  25. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/it-IT/Sophia.psd1
  26. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pl-PL/Sophia.psd1
  27. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/pt-BR/Sophia.psd1
  28. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/ru-RU/Sophia.psd1
  29. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/tr-TR/Sophia.psd1
  30. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/uk-UA/Sophia.psd1
  31. 1
      src/Sophia_Script_for_Windows_10_LTSC_2019/Localizations/zh-CN/Sophia.psd1
  32. 2
      src/Sophia_Script_for_Windows_10_LTSC_2019/Manifest/Sophia.psd1
  33. 289
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  34. 10
      src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
  35. 6
      src/Sophia_Script_for_Windows_10_LTSC_2021/Functions.ps1
  36. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/de-DE/Sophia.psd1
  37. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/en-US/Sophia.psd1
  38. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/es-ES/Sophia.psd1
  39. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/fr-FR/Sophia.psd1
  40. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/hu-HU/Sophia.psd1
  41. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/it-IT/Sophia.psd1
  42. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pl-PL/Sophia.psd1
  43. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/pt-BR/Sophia.psd1
  44. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/ru-RU/Sophia.psd1
  45. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/tr-TR/Sophia.psd1
  46. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/uk-UA/Sophia.psd1
  47. 1
      src/Sophia_Script_for_Windows_10_LTSC_2021/Localizations/zh-CN/Sophia.psd1
  48. 2
      src/Sophia_Script_for_Windows_10_LTSC_2021/Manifest/Sophia.psd1
  49. 330
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  50. 10
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  51. 6
      src/Sophia_Script_for_Windows_10_PowerShell_7/Functions.ps1
  52. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/de-DE/Sophia.psd1
  53. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/en-US/Sophia.psd1
  54. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/es-ES/Sophia.psd1
  55. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/fr-FR/Sophia.psd1
  56. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/hu-HU/Sophia.psd1
  57. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/it-IT/Sophia.psd1
  58. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pl-PL/Sophia.psd1
  59. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/pt-BR/Sophia.psd1
  60. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/ru-RU/Sophia.psd1
  61. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/tr-TR/Sophia.psd1
  62. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/uk-UA/Sophia.psd1
  63. 1
      src/Sophia_Script_for_Windows_10_PowerShell_7/Localizations/zh-CN/Sophia.psd1
  64. 2
      src/Sophia_Script_for_Windows_10_PowerShell_7/Manifest/Sophia.psd1
  65. 431
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  66. 10
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  67. 6
      src/Sophia_Script_for_Windows_11/Functions.ps1
  68. 1
      src/Sophia_Script_for_Windows_11/Localizations/de-DE/Sophia.psd1
  69. 1
      src/Sophia_Script_for_Windows_11/Localizations/en-US/Sophia.psd1
  70. 1
      src/Sophia_Script_for_Windows_11/Localizations/es-ES/Sophia.psd1
  71. 1
      src/Sophia_Script_for_Windows_11/Localizations/fr-FR/Sophia.psd1
  72. 1
      src/Sophia_Script_for_Windows_11/Localizations/hu-HU/Sophia.psd1
  73. 1
      src/Sophia_Script_for_Windows_11/Localizations/it-IT/Sophia.psd1
  74. 1
      src/Sophia_Script_for_Windows_11/Localizations/pl-PL/Sophia.psd1
  75. 1
      src/Sophia_Script_for_Windows_11/Localizations/pt-BR/Sophia.psd1
  76. 1
      src/Sophia_Script_for_Windows_11/Localizations/ru-RU/Sophia.psd1
  77. 1
      src/Sophia_Script_for_Windows_11/Localizations/tr-TR/Sophia.psd1
  78. 1
      src/Sophia_Script_for_Windows_11/Localizations/uk-UA/Sophia.psd1
  79. 1
      src/Sophia_Script_for_Windows_11/Localizations/zh-CN/Sophia.psd1
  80. 2
      src/Sophia_Script_for_Windows_11/Manifest/Sophia.psd1
  81. 472
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  82. 6
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  83. 6
      src/Sophia_Script_for_Windows_11_PowerShell_7/Functions.ps1
  84. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/de-DE/Sophia.psd1
  85. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/en-US/Sophia.psd1
  86. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/es-ES/Sophia.psd1
  87. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/fr-FR/Sophia.psd1
  88. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/hu-HU/Sophia.psd1
  89. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/it-IT/Sophia.psd1
  90. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pl-PL/Sophia.psd1
  91. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/pt-BR/Sophia.psd1
  92. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/ru-RU/Sophia.psd1
  93. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/tr-TR/Sophia.psd1
  94. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/uk-UA/Sophia.psd1
  95. 1
      src/Sophia_Script_for_Windows_11_PowerShell_7/Localizations/zh-CN/Sophia.psd1
  96. 2
      src/Sophia_Script_for_Windows_11_PowerShell_7/Manifest/Sophia.psd1
  97. 470
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  98. 10
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

BIN
Wrapper/SophiaScriptWrapper.exe

Binary file not shown.

14
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"
}

6
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) 20142024 farag
Copyright (c) 20192024 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

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}"

2
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'

431
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) 20142024 farag
Copyright (c) 20192024 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
}
}
}

10
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) 20142024 farag
Copyright (c) 20192024 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
#>

6
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) 20142024 farag
Copyright (c) 20192024 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

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}"

2
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'

289
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) 20142024 farag
Copyright (c) 20192024 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"

10
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) 20142024 farag
Copyright (c) 20192024 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
#>

6
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) 20142024 farag
Copyright (c) 20192024 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

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}"

2
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'

330
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) 20142024 farag
Copyright (c) 20192024 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
}
}
}

10
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) 20142024 farag
Copyright (c) 20192024 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
#>

6
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) 20142024 farag
Copyright (c) 20192024 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

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}"

2
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'

431
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) 20142024 farag
Copyright (c) 20192024 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
}
}
}

10
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) 20142024 farag
Copyright (c) 20192024 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
#>

6
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) 20142024 farag
Copyright (c) 20192024 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

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}"

2
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'

472
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) 20142024 farag
Copyright (c) 20192024 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
}
<#

6
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) 20142024 farag
Copyright (c) 20192024 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

6
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) 20142024 farag
Copyright (c) 20192024 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

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}".

1
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}"

2
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'

470
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) 20142024 farag
Copyright (c) 20192024 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
}
<#

10
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) 20142024 farag
Copyright (c) 20192024 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
#>

Loading…
Cancel
Save