Browse Source

Added new functions...

pull/450/head
Dmitry Nefedov 2 years ago
parent
commit
2e089c404a
  1. 34
      Wrapper/Config/config_Windows_10.json
  2. 34
      Wrapper/Config/config_Windows_10_LTSC.json
  3. 34
      Wrapper/Config/config_Windows_11.json
  4. 30
      Wrapper/Localizations/de-DE/tooltip_Windows_10.json
  5. 30
      Wrapper/Localizations/de-DE/tooltip_Windows_11.json
  6. 30
      Wrapper/Localizations/en-US/tooltip_Windows_10.json
  7. 30
      Wrapper/Localizations/en-US/tooltip_Windows_11.json
  8. 30
      Wrapper/Localizations/ru-RU/tooltip_Windows_10.json
  9. 30
      Wrapper/Localizations/ru-RU/tooltip_Windows_11.json
  10. BIN
      Wrapper/SophiaScriptWrapper.exe
  11. 231
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  12. 16
      src/Sophia_Script_for_Windows_10/Sophia.ps1
  13. 231
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  14. 16
      src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1
  15. 231
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  16. 16
      src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1
  17. 235
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  18. 16
      src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1
  19. 161
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  20. 14
      src/Sophia_Script_for_Windows_11/Sophia.ps1
  21. 165
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1
  22. 16
      src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

34
Wrapper/Config/config_Windows_10.json

@ -958,6 +958,40 @@
"Preset": "One",
"WindowsDefault": "Zero"
},
{
"Id": 339,
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None"
},
"One": {
"Tag": "Default"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Id": 340,
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable"
},
"One": {
"Tag": "Enable"
}
},
"Preset": "Zero",
"WindowsDefault": "Zero"
},
{
"Id": 400,
"Region": "OneDrive",

34
Wrapper/Config/config_Windows_10_LTSC.json

@ -1068,6 +1068,40 @@
"Preset": "One",
"WindowsDefault": "Zero"
},
{
"Id": 339,
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None"
},
"One": {
"Tag": "Default"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Id": 340,
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable"
},
"One": {
"Tag": "Enable"
}
},
"Preset": "Zero",
"WindowsDefault": "Zero"
},
{
"Id": 400,
"Region": "OneDrive",

34
Wrapper/Config/config_Windows_11.json

@ -832,6 +832,40 @@
"Preset": "One",
"WindowsDefault": "Zero"
},
{
"Id": 331,
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None"
},
"One": {
"Tag": "Default"
}
},
"Preset": "Zero",
"WindowsDefault": "One"
},
{
"Id": 332,
"Region": "UI & Personalization",
"Control": "cmb",
"Required": "false",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable"
},
"One": {
"Tag": "Enable"
}
},
"Preset": "Zero",
"WindowsDefault": "Zero"
},
{
"Id": 400,
"Region": "OneDrive",

30
Wrapper/Localizations/de-DE/tooltip_Windows_10.json

@ -863,6 +863,36 @@
}
}
},
{
"Id": 339,
"Region": "UI & Personalization",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None",
"ToolTip": "Gruppieren Sie keine Dateien und Ordner im Ordner \"Downloads\""
},
"One": {
"Tag": "Default",
"ToolTip": "Gruppieren Sie Dateien und Ordner im Ordner \"Downloads\" nach Änderungsdatum"
}
}
},
{
"Id": 340,
"Region": "UI & Personalization",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Erweitern Sie nicht, um den Ordner im Navigationsbereich zu öffnen (Standardeinstellung)"
},
"One": {
"Tag": "Enable",
"ToolTip": "Erweitern, um den Ordner im Navigationsbereich zu öffnen"
}
}
},
{
"Id": 400,
"Region": "OneDrive",

30
Wrapper/Localizations/de-DE/tooltip_Windows_11.json

@ -750,6 +750,36 @@
}
}
},
{
"Id": 332,
"Region": "UI & Personalization",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None",
"ToolTip": "Gruppieren Sie keine Dateien und Ordner im Ordner \"Downloads\""
},
"One": {
"Tag": "Default",
"ToolTip": "Gruppieren Sie Dateien und Ordner im Ordner \"Downloads\" nach Änderungsdatum"
}
}
},
{
"Id": 333,
"Region": "UI & Personalization",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Erweitern Sie nicht, um den Ordner im Navigationsbereich zu öffnen (Standardeinstellung)"
},
"One": {
"Tag": "Enable",
"ToolTip": "Erweitern, um den Ordner im Navigationsbereich zu öffnen"
}
}
},
{
"Id": 400,
"Region": "OneDrive",

30
Wrapper/Localizations/en-US/tooltip_Windows_10.json

@ -863,6 +863,36 @@
}
}
},
{
"Id": 339,
"Region": "UI & Personalization",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None",
"ToolTip": "Do not group files and folder in the Downloads folder"
},
"One": {
"Tag": "Default",
"ToolTip": "Group files and folder by date modified in the Downloads folder"
}
}
},
{
"Id": 340,
"Region": "UI & Personalization",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Do not expand to open folder on navigation pane (default value)"
},
"One": {
"Tag": "Enable",
"ToolTip": "Expand to open folder on navigation pane"
}
}
},
{
"Id": 400,
"Region": "OneDrive",

30
Wrapper/Localizations/en-US/tooltip_Windows_11.json

@ -750,6 +750,36 @@
}
}
},
{
"Id": 339,
"Region": "UI & Personalization",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None",
"ToolTip": "Do not group files and folder in the Downloads folder"
},
"One": {
"Tag": "Default",
"ToolTip": "Group files and folder by date modified in the Downloads folder"
}
}
},
{
"Id": 340,
"Region": "UI & Personalization",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Do not expand to open folder on navigation pane (default value)"
},
"One": {
"Tag": "Enable",
"ToolTip": "Expand to open folder on navigation pane"
}
}
},
{
"Id": 400,
"Region": "OneDrive",

30
Wrapper/Localizations/ru-RU/tooltip_Windows_10.json

@ -863,6 +863,36 @@
}
}
},
{
"Id": 339,
"Region": "UI & Personalization",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None",
"ToolTip": "Не группировать файлы и папки в папке Загрузки"
},
"One": {
"Tag": "Default",
"ToolTip": "Группировать файлы и папки по дате изменения (значение по умолчанию)"
}
}
},
{
"Id": 340,
"Region": "UI & Personalization",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Не разворачивать до открытой папки область навигации (значение по умолчанию)"
},
"One": {
"Tag": "Enable",
"ToolTip": "Развернуть до открытой папки область навигации"
}
}
},
{
"Id": 400,
"Region": "OneDrive",

30
Wrapper/Localizations/ru-RU/tooltip_Windows_11.json

@ -750,6 +750,36 @@
}
}
},
{
"Id": 332,
"Region": "UI & Personalization",
"Function": "FolderGroupBy",
"Arg": {
"Zero": {
"Tag": "None",
"ToolTip": "Не группировать файлы и папки в папке Загрузки"
},
"One": {
"Tag": "Default",
"ToolTip": "Группировать файлы и папки по дате изменения (значение по умолчанию)"
}
}
},
{
"Id": 333,
"Region": "UI & Personalization",
"Function": "NavigationPaneExpand",
"Arg": {
"Zero": {
"Tag": "Disable",
"ToolTip": "Не разворачивать до открытой папки область навигации (значение по умолчанию)"
},
"One": {
"Tag": "Enable",
"ToolTip": "Развернуть до открытой папки область навигации"
}
}
},
{
"Id": 400,
"Region": "OneDrive",

BIN
Wrapper/SophiaScriptWrapper.exe

Binary file not shown.

231
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -4271,6 +4271,122 @@ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint
}
[WinAPI.SystemParamInfo]::SystemParametersInfo(0x0057, 0, $null, 0)
}
<#
.SYNOPSIS
Files and folders grouping in the Downloads folder
.PARAMETER None
Do not group files and folder in the Downloads folder
.PARAMETER Default
Group files and folder by date modified in the Downloads folder (default value)
.EXAMPLE
FolderGroupBy -None
.EXAMPLE
FolderGroupBy -Default
.NOTES
Current user
#>
function FolderGroupBy
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "None"
)]
[switch]
$None,
[Parameter(
Mandatory = $true,
ParameterSetName = "Default"
)]
[switch]
$Default
)
switch ($PSCmdlet.ParameterSetName)
{
"None"
{
# Clear any Common Dialog views
Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\*\Shell" -Recurse | Where-Object -FilterScript {$_.PSChildName -eq "{885A186E-A440-4ADA-812B-DB871B942259}"} | Remove-Item -Force
# https://learn.microsoft.com/en-us/windows/win32/properties/props-system-null
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"))
{
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Force
}
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name GroupBy -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name LogicalViewMode -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Name -PropertyType String -Value NoName -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Order -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name PrimaryProperty -PropertyType String -Value "System.ItemNameDisplay" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name SortByList -PropertyType String -Value "prop:System.ItemNameDisplay" -Force
}
"Default"
{
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}" -Recurse -Force -ErrorAction Ignore
}
}
}
<#
.SYNOPSIS
Expand to current folder in navigation pane
.PARAMETER Disable
Do not expand to open folder on navigation pane (default value)
.PARAMETER Enable
Expand to open folder on navigation pane
.EXAMPLE
NavigationPaneExpand -Disable
.EXAMPLE
NavigationPaneExpand -Enable
.NOTES
Current user
#>
function NavigationPaneExpand
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Disable"
)]
[switch]
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
)]
[switch]
$Enable
)
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore
}
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 1 -Force
}
}
}
#endregion UI & Personalization
#region OneDrive
@ -11815,7 +11931,7 @@ function SoftwareDistributionTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11993,7 +12109,7 @@ function TempTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -14041,9 +14157,10 @@ function UpdateLGPEPolicies
}
#endregion Update Policies
#region Refresh Environment
function RefreshEnvironment
#region Post Actions
function PostActions
{
#region Refresh Environment
$UpdateEnvironment = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
@ -14102,7 +14219,9 @@ public static void PostMessage()
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled)
{
@ -14112,6 +14231,12 @@ public static void PostMessage()
}
}
if ($Script:RegionChanged)
{
# Set the original region ID
Set-WinHomeLocation -GeoId $Script:Region
}
# Persist Sophia notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
@ -14131,6 +14256,49 @@ public static void PostMessage()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its' own database
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Telegram group
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
@ -14211,58 +14379,11 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# [WinAPI.UpdateEnvironment]::Refresh() makes so that Meet Now icon returns even if was hid before, so we need to check which function was called previously
if ($Script:MeetNow)
{
MeetNow -Show
}
elseif ($Script:MeetNow -eq $false)
{
MeetNow -Hide
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Toast notifications
}
#endregion Post Actions
#region Errors
function Errors
{
if ($Global:Error)
@ -14285,4 +14406,4 @@ function Errors
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}
#endregion Refresh Environment
#endregion Errors

16
src/Sophia_Script_for_Windows_10/Sophia.ps1

@ -567,6 +567,22 @@ Cursors -Dark
# Set default cursors (default value)
# Установить курсоры по умолчанию (значение по умолчанию)
# Cursors -Default
# Do not group files and folder in the Downloads folder
# Не группировать файлы и папки в папке Загрузки
FolderGroupBy -None
# Group files and folder by date modified in the Downloads folder (default value)
# Группировать файлы и папки по дате изменения (значение по умолчанию)
# FolderGroupBy -Default
# Do not expand to open folder on navigation pane (default value)
# Не разворачивать до открытой папки область навигации (значение по умолчанию)
NavigationPaneExpand -Disable
# Expand to open folder on navigation pane
# Развернуть до открытой папки область навигации
# NavigationPaneExpand -Enable
#endregion UI & Personalization
#region OneDrive

231
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -3241,6 +3241,122 @@ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint
}
[WinAPI.SystemParamInfo]::SystemParametersInfo(0x0057, 0, $null, 0)
}
<#
.SYNOPSIS
Files and folders grouping in the Downloads folder
.PARAMETER None
Do not group files and folder in the Downloads folder
.PARAMETER Default
Group files and folder by date modified in the Downloads folder (default value)
.EXAMPLE
FolderGroupBy -None
.EXAMPLE
FolderGroupBy -Default
.NOTES
Current user
#>
function FolderGroupBy
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "None"
)]
[switch]
$None,
[Parameter(
Mandatory = $true,
ParameterSetName = "Default"
)]
[switch]
$Default
)
switch ($PSCmdlet.ParameterSetName)
{
"None"
{
# Clear any Common Dialog views
Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\*\Shell" -Recurse | Where-Object -FilterScript {$_.PSChildName -eq "{885A186E-A440-4ADA-812B-DB871B942259}"} | Remove-Item -Force
# https://learn.microsoft.com/en-us/windows/win32/properties/props-system-null
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"))
{
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Force
}
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name GroupBy -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name LogicalViewMode -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Name -PropertyType String -Value NoName -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Order -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name PrimaryProperty -PropertyType String -Value "System.ItemNameDisplay" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name SortByList -PropertyType String -Value "prop:System.ItemNameDisplay" -Force
}
"Default"
{
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}" -Recurse -Force -ErrorAction Ignore
}
}
}
<#
.SYNOPSIS
Expand to current folder in navigation pane
.PARAMETER Disable
Do not expand to open folder on navigation pane (default value)
.PARAMETER Enable
Expand to open folder on navigation pane
.EXAMPLE
NavigationPaneExpand -Disable
.EXAMPLE
NavigationPaneExpand -Enable
.NOTES
Current user
#>
function NavigationPaneExpand
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Disable"
)]
[switch]
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
)]
[switch]
$Enable
)
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore
}
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 1 -Force
}
}
}
#endregion UI & Personalization
#region System
@ -8457,7 +8573,7 @@ function SoftwareDistributionTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -8635,7 +8751,7 @@ function TempTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -10461,9 +10577,10 @@ function UpdateLGPEPolicies
}
#endregion Update Policies
#region Refresh Environment
function RefreshEnvironment
#region Post Actions
function PostActions
{
#region Refresh Environment
$UpdateEnvironment = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
@ -10522,7 +10639,9 @@ public static void PostMessage()
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled)
{
@ -10532,6 +10651,12 @@ public static void PostMessage()
}
}
if ($Script:RegionChanged)
{
# Set the original region ID
Set-WinHomeLocation -GeoId $Script:Region
}
# Persist Sophia notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
@ -10551,6 +10676,49 @@ public static void PostMessage()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its' own database
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Telegram group
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
@ -10631,58 +10799,11 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# [WinAPI.UpdateEnvironment]::Refresh() makes so that Meet Now icon returns even if was hid before, so we need to check which function was called previously
if ($Script:MeetNow)
{
MeetNow -Show
}
elseif ($Script:MeetNow -eq $false)
{
MeetNow -Hide
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Toast notifications
}
#endregion Post Actions
#region Errors
function Errors
{
if ($Global:Error)
@ -10705,4 +10826,4 @@ function Errors
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}
#endregion Refresh Environment
#endregion Errors

16
src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1

@ -439,6 +439,22 @@ Cursors -Dark
# Set default cursors (default value)
# Установить курсоры по умолчанию (значение по умолчанию)
# Cursors -Default
# Do not group files and folder in the Downloads folder
# Не группировать файлы и папки в папке Загрузки
FolderGroupBy -None
# Group files and folder by date modified in the Downloads folder (default value)
# Группировать файлы и папки по дате изменения (значение по умолчанию)
# FolderGroupBy -Default
# Do not expand to open folder on navigation pane (default value)
# Не разворачивать до открытой папки область навигации (значение по умолчанию)
NavigationPaneExpand -Disable
# Expand to open folder on navigation pane
# Развернуть до открытой папки область навигации
# NavigationPaneExpand -Enable
#endregion UI & Personalization
#region System

231
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -3612,6 +3612,122 @@ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint
}
[WinAPI.SystemParamInfo]::SystemParametersInfo(0x0057, 0, $null, 0)
}
<#
.SYNOPSIS
Files and folders grouping in the Downloads folder
.PARAMETER None
Do not group files and folder in the Downloads folder
.PARAMETER Default
Group files and folder by date modified in the Downloads folder (default value)
.EXAMPLE
FolderGroupBy -None
.EXAMPLE
FolderGroupBy -Default
.NOTES
Current user
#>
function FolderGroupBy
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "None"
)]
[switch]
$None,
[Parameter(
Mandatory = $true,
ParameterSetName = "Default"
)]
[switch]
$Default
)
switch ($PSCmdlet.ParameterSetName)
{
"None"
{
# Clear any Common Dialog views
Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\*\Shell" -Recurse | Where-Object -FilterScript {$_.PSChildName -eq "{885A186E-A440-4ADA-812B-DB871B942259}"} | Remove-Item -Force
# https://learn.microsoft.com/en-us/windows/win32/properties/props-system-null
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"))
{
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Force
}
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name GroupBy -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name LogicalViewMode -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Name -PropertyType String -Value NoName -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Order -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name PrimaryProperty -PropertyType String -Value "System.ItemNameDisplay" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name SortByList -PropertyType String -Value "prop:System.ItemNameDisplay" -Force
}
"Default"
{
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}" -Recurse -Force -ErrorAction Ignore
}
}
}
<#
.SYNOPSIS
Expand to current folder in navigation pane
.PARAMETER Disable
Do not expand to open folder on navigation pane (default value)
.PARAMETER Enable
Expand to open folder on navigation pane
.EXAMPLE
NavigationPaneExpand -Disable
.EXAMPLE
NavigationPaneExpand -Enable
.NOTES
Current user
#>
function NavigationPaneExpand
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Disable"
)]
[switch]
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
)]
[switch]
$Enable
)
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore
}
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 1 -Force
}
}
}
#endregion UI & Personalization
#region System
@ -9568,7 +9684,7 @@ function SoftwareDistributionTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -9746,7 +9862,7 @@ function TempTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11626,9 +11742,10 @@ function UpdateLGPEPolicies
}
#endregion Update Policies
#region Refresh Environment
function RefreshEnvironment
#region Post Actions
function PostActions
{
#region Refresh Environment
$UpdateEnvironment = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
@ -11687,7 +11804,9 @@ public static void PostMessage()
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled)
{
@ -11697,6 +11816,12 @@ public static void PostMessage()
}
}
if ($Script:RegionChanged)
{
# Set the original region ID
Set-WinHomeLocation -GeoId $Script:Region
}
# Persist Sophia notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
@ -11716,6 +11841,49 @@ public static void PostMessage()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its' own database
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Telegram group
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
@ -11796,58 +11964,11 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# [WinAPI.UpdateEnvironment]::Refresh() makes so that Meet Now icon returns even if was hid before, so we need to check which function was called previously
if ($Script:MeetNow)
{
MeetNow -Show
}
elseif ($Script:MeetNow -eq $false)
{
MeetNow -Hide
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Toast notifications
}
#endregion Post Actions
#region Errors
function Errors
{
if ($Global:Error)
@ -11870,4 +11991,4 @@ function Errors
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}
#endregion Refresh Environment
#endregion Errors

16
src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1

@ -494,6 +494,22 @@ Cursors -Dark
# Set default cursors (default value)
# Установить курсоры по умолчанию (значение по умолчанию)
# Cursors -Default
# Do not group files and folder in the Downloads folder
# Не группировать файлы и папки в папке Загрузки
FolderGroupBy -None
# Group files and folder by date modified in the Downloads folder (default value)
# Группировать файлы и папки по дате изменения (значение по умолчанию)
# FolderGroupBy -Default
# Do not expand to open folder on navigation pane (default value)
# Не разворачивать до открытой папки область навигации (значение по умолчанию)
NavigationPaneExpand -Disable
# Expand to open folder on navigation pane
# Развернуть до открытой папки область навигации
# NavigationPaneExpand -Enable
#endregion UI & Personalization
#region System

235
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -4273,6 +4273,122 @@ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint
}
[WinAPI.SystemParamInfo]::SystemParametersInfo(0x0057, 0, $null, 0)
}
<#
.SYNOPSIS
Files and folders grouping in the Downloads folder
.PARAMETER None
Do not group files and folder in the Downloads folder
.PARAMETER Default
Group files and folder by date modified in the Downloads folder (default value)
.EXAMPLE
FolderGroupBy -None
.EXAMPLE
FolderGroupBy -Default
.NOTES
Current user
#>
function FolderGroupBy
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "None"
)]
[switch]
$None,
[Parameter(
Mandatory = $true,
ParameterSetName = "Default"
)]
[switch]
$Default
)
switch ($PSCmdlet.ParameterSetName)
{
"None"
{
# Clear any Common Dialog views
Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\*\Shell" -Recurse | Where-Object -FilterScript {$_.PSChildName -eq "{885A186E-A440-4ADA-812B-DB871B942259}"} | Remove-Item -Force
# https://learn.microsoft.com/en-us/windows/win32/properties/props-system-null
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"))
{
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Force
}
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name GroupBy -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name LogicalViewMode -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Name -PropertyType String -Value NoName -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Order -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name PrimaryProperty -PropertyType String -Value "System.ItemNameDisplay" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name SortByList -PropertyType String -Value "prop:System.ItemNameDisplay" -Force
}
"Default"
{
Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}" -Recurse -Force -ErrorAction Ignore
}
}
}
<#
.SYNOPSIS
Expand to current folder in navigation pane
.PARAMETER Disable
Do not expand to open folder on navigation pane (default value)
.PARAMETER Enable
Expand to open folder on navigation pane
.EXAMPLE
NavigationPaneExpand -Disable
.EXAMPLE
NavigationPaneExpand -Enable
.NOTES
Current user
#>
function NavigationPaneExpand
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Disable"
)]
[switch]
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
)]
[switch]
$Enable
)
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore
}
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 1 -Force
}
}
}
#endregion UI & Personalization
#region OneDrive
@ -11843,7 +11959,7 @@ function SoftwareDistributionTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -12021,7 +12137,7 @@ function TempTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -14071,9 +14187,10 @@ function UpdateLGPEPolicies
}
#endregion Update Policies
#region Refresh Environment
function RefreshEnvironment
#region Post Actions
function PostActions
{
#region Refresh Environment
$UpdateEnvironment = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
@ -14132,7 +14249,9 @@ public static void PostMessage()
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled)
{
@ -14142,6 +14261,12 @@ public static void PostMessage()
}
}
if ($Script:RegionChanged)
{
# Set the original region ID
Set-WinHomeLocation -GeoId $Script:Region
}
# Persist Sophia notifications to prevent to immediately disappear from Action Center
if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia))
{
@ -14158,9 +14283,52 @@ public static void PostMessage()
# Determines whether the app can be seen in Settings where the user can turn notifications on or off
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Name ShowInSettings -Value 0 -PropertyType DWord -Force
Add-Type -AssemblyName "$PSScriptRoot\..\bin\WinRT.Runtime.dll"
Add-Type -AssemblyName "$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its' own database
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Telegram group
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
@ -14241,58 +14409,11 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# [WinAPI.UpdateEnvironment]::Refresh() makes so that Meet Now icon returns even if was hid before, so we need to check which function was called previously
if ($Script:MeetNow)
{
MeetNow -Show
}
elseif ($Script:MeetNow -eq $false)
{
MeetNow -Hide
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Toast notifications
}
#endregion Post Actions
#region Errors
function Errors
{
if ($Global:Error)
@ -14315,4 +14436,4 @@ function Errors
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}
#endregion Refresh Environment
#endregion Errors

16
src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1

@ -576,6 +576,22 @@ Cursors -Dark
# Set default cursors (default value)
# Установить курсоры по умолчанию (значение по умолчанию)
# Cursors -Default
# Do not group files and folder in the Downloads folder
# Не группировать файлы и папки в папке Загрузки
FolderGroupBy -None
# Group files and folder by date modified in the Downloads folder (default value)
# Группировать файлы и папки по дате изменения (значение по умолчанию)
# FolderGroupBy -Default
# Do not expand to open folder on navigation pane (default value)
# Не разворачивать до открытой папки область навигации (значение по умолчанию)
NavigationPaneExpand -Disable
# Expand to open folder on navigation pane
# Развернуть до открытой папки область навигации
# NavigationPaneExpand -Enable
#endregion UI & Personalization
#region OneDrive

161
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -3754,13 +3754,13 @@ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint
<#
.SYNOPSIS
Files and folders grouping
Files and folders grouping in the Downloads folder
.PARAMETER None
Do not group files and folder
Do not group files and folder in the Downloads folder
.PARAMETER Default
Group files and folder by date modified (default value)
Group files and folder by date modified in the Downloads folder (default value)
.EXAMPLE
FolderGroupBy -None
@ -3797,14 +3797,17 @@ function FolderGroupBy
# Clear any Common Dialog views
Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\*\Shell" -Recurse | Where-Object -FilterScript {$_.PSChildName -eq "{885A186E-A440-4ADA-812B-DB871B942259}"} | Remove-Item -Force
# https://learn.microsoft.com/en-us/windows/win32/properties/props-system-null
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"))
{
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Force
}
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "prop:0(34)System.ItemNameDisplay;0System.DateModified;0System.ItemTypeText;0System.Size;1System.DateCreated;1System.Author;1System.Category;1System.Keywords;1System.Title" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name GroupBy -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name LogicalViewMode -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Name -PropertyType String -Value NoName -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Order -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name PrimaryProperty -PropertyType String -Value "System.ItemNameDisplay" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name SortByList -PropertyType String -Value "prop:System.ItemNameDisplay" -Force
}
"Default"
@ -3813,6 +3816,57 @@ function FolderGroupBy
}
}
}
<#
.SYNOPSIS
Expand to current folder in navigation pane
.PARAMETER Disable
Do not expand to open folder on navigation pane (default value)
.PARAMETER Enable
Expand to open folder on navigation pane
.EXAMPLE
NavigationPaneExpand -Disable
.EXAMPLE
NavigationPaneExpand -Enable
.NOTES
Current user
#>
function NavigationPaneExpand
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Disable"
)]
[switch]
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
)]
[switch]
$Enable
)
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore
}
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 1 -Force
}
}
}
#endregion UI & Personalization
#region OneDrive
@ -11283,7 +11337,7 @@ function SoftwareDistributionTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11461,7 +11515,7 @@ function TempTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -13455,9 +13509,10 @@ function UpdateLGPEPolicies
}
#endregion Update Policies
#region Refresh Environment
function RefreshEnvironment
#region Post Actions
function PostActions
{
#region Refresh Environment
$UpdateEnvironment = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
@ -13516,7 +13571,9 @@ public static void PostMessage()
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled)
{
@ -13551,6 +13608,49 @@ public static void PostMessage()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its' own database
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Telegram group
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
@ -13631,48 +13731,11 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Toast notifications
}
#endregion Post Actions
#region Errors
function Errors
{
if ($Global:Error)
@ -13695,4 +13758,4 @@ function Errors
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}
#endregion Refresh Environment
#endregion Errors

14
src/Sophia_Script_for_Windows_11/Sophia.ps1

@ -507,13 +507,21 @@ Cursors -Dark
# Установить курсоры по умолчанию (значение по умолчанию)
# Cursors -Default
# Do not group files and folder
# Не группировать файлы и папки
# Do not group files and folder in the Downloads folder
# Не группировать файлы и папки в папке Загрузки
FolderGroupBy -None
# Group files and folder by date modified (default value)
# Group files and folder by date modified in the Downloads folder (default value)
# Группировать файлы и папки по дате изменения (значение по умолчанию)
# FolderGroupBy -Default
# Do not expand to open folder on navigation pane (default value)
# Не разворачивать до открытой папки область навигации (значение по умолчанию)
NavigationPaneExpand -Disable
# Expand to open folder on navigation pane
# Развернуть до открытой папки область навигации
# NavigationPaneExpand -Enable
#endregion UI & Personalization
#region OneDrive

165
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -3756,13 +3756,13 @@ public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint
<#
.SYNOPSIS
Files and folders grouping
Files and folders grouping in the Downloads folder
.PARAMETER None
Do not group files and folder
Do not group files and folder in the Downloads folder
.PARAMETER Default
Group files and folder by date modified (default value)
Group files and folder by date modified in the Downloads folder (default value)
.EXAMPLE
FolderGroupBy -None
@ -3799,14 +3799,17 @@ function FolderGroupBy
# Clear any Common Dialog views
Get-ChildItem -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\*\Shell" -Recurse | Where-Object -FilterScript {$_.PSChildName -eq "{885A186E-A440-4ADA-812B-DB871B942259}"} | Remove-Item -Force
# https://learn.microsoft.com/en-us/windows/win32/properties/props-system-null
if (-not (Test-Path -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}"))
{
New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Force
}
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "prop:0(34)System.ItemNameDisplay;0System.DateModified;0System.ItemTypeText;0System.Size;1System.DateCreated;1System.Author;1System.Category;1System.Keywords;1System.Title" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name ColumnList -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name GroupBy -PropertyType String -Value "System.Null" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name LogicalViewMode -PropertyType DWord -Value 1 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Name -PropertyType String -Value NoName -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name Order -PropertyType DWord -Value 0 -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name PrimaryProperty -PropertyType String -Value "System.ItemNameDisplay" -Force
New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{885a186e-a440-4ada-812b-db871b942259}\TopViews\{00000000-0000-0000-0000-000000000000}" -Name SortByList -PropertyType String -Value "prop:System.ItemNameDisplay" -Force
}
"Default"
@ -3815,6 +3818,57 @@ function FolderGroupBy
}
}
}
<#
.SYNOPSIS
Expand to current folder in navigation pane
.PARAMETER Disable
Do not expand to open folder on navigation pane (default value)
.PARAMETER Enable
Expand to open folder on navigation pane
.EXAMPLE
NavigationPaneExpand -Disable
.EXAMPLE
NavigationPaneExpand -Enable
.NOTES
Current user
#>
function NavigationPaneExpand
{
param
(
[Parameter(
Mandatory = $true,
ParameterSetName = "Disable"
)]
[switch]
$Disable,
[Parameter(
Mandatory = $true,
ParameterSetName = "Enable"
)]
[switch]
$Enable
)
switch ($PSCmdlet.ParameterSetName)
{
"Disable"
{
Remove-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -Force -ErrorAction Ignore
}
"Enable"
{
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name NavPaneExpandToCurrentFolder -PropertyType DWord -Value 1 -Force
}
}
}
#endregion UI & Personalization
#region OneDrive
@ -11311,7 +11365,7 @@ function SoftwareDistributionTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName SoftwareDistribution -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\SoftwareDistribution to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -11489,7 +11543,7 @@ function TempTask
"Register"
{
# Checking if we're trying to create the task when it was already created as another user
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp)
if (Get-ScheduledTask -TaskPath "\Sophia\" -TaskName Temp -ErrorAction Ignore)
{
# Also we can parse $env:SystemRoot\System32\Tasks\Sophia\Temp to check if the task was created
$ScheduleService = New-Object -ComObject Schedule.Service
@ -13482,9 +13536,10 @@ function UpdateLGPEPolicies
}
#endregion Update Policies
#region Refresh Environment
function RefreshEnvironment
#region Post Actions
function PostActions
{
#region Refresh Environment
$UpdateEnvironment = @{
Namespace = "WinAPI"
Name = "UpdateEnvironment"
@ -13543,7 +13598,9 @@ public static void PostMessage()
# Restart the Start menu
Stop-Process -Name StartMenuExperienceHost -Force -ErrorAction Ignore
#endregion Refresh Environment
#region Other actions
# Turn on Controlled folder access if it was turned off
if ($Script:DefenderEnabled)
{
@ -13575,9 +13632,52 @@ public static void PostMessage()
# Determines whether the app can be seen in Settings where the user can turn notifications on or off
New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Name ShowInSettings -Value 0 -PropertyType DWord -Force
Add-Type -AssemblyName "$PSScriptRoot\..\bin\WinRT.Runtime.dll"
Add-Type -AssemblyName "$PSScriptRoot\..\bin\Microsoft.Windows.SDK.NET.dll"
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null
# Apply policies found in registry to re-build database database due to gpedit.msc relies in its' own database
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Other actions
#region Toast notifications
# Telegram group
[xml]$ToastTemplate = @"
<toast duration="Long" scenario="reminder">
@ -13658,48 +13758,11 @@ public static void PostMessage()
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage)
if ((Test-Path -Path "$env:TEMP\Computer.txt") -or (Test-Path -Path "$env:TEMP\User.txt"))
{
if (Test-Path -Path "$env:TEMP\Computer.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\Computer.txt"
}
if (Test-Path -Path "$env:TEMP\User.txt")
{
& "$PSScriptRoot\..\bin\LGPO.exe" /t "$env:TEMP\User.txt"
}
gpupdate /force
}
# PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
Stop-Process -Name explorer -Force
Start-Sleep -Seconds 3
# Restoring closed folders
foreach ($Script:OpenedFolder in $Script:OpenedFolders)
{
if (Test-Path -Path $Script:OpenedFolder)
{
Start-Process -FilePath explorer -ArgumentList $Script:OpenedFolder
}
}
# Check if any of scheduled tasks were created. Unless open Task Scheduler
# Check how the script was invoked: via a preset or Function.ps1
$PresetName = (Get-PSCallStack).Position | Where-Object -FilterScript {
(($_.File -match ".ps1") -and ($_.File -notmatch "Functions.ps1")) -and (($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "CleanupTask -Register") -or ($_.Text -eq "TempTask -Register")) -or ($_.Text -match "Invoke-Expression")
}
if ($PresetName)
{
# Open Task Scheduler
Start-Process -FilePath taskschd.msc
}
#endregion Toast notifications
}
#endregion Post Actions
#region Errors
function Errors
{
if ($Global:Error)
@ -13722,4 +13785,4 @@ function Errors
Write-Information -MessageData "" -InformationAction Continue
Write-Warning -Message $Localization.RestartWarning
}
#endregion Refresh Environment
#endregion Errors

16
src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1

@ -516,13 +516,21 @@ Cursors -Dark
# Установить курсоры по умолчанию (значение по умолчанию)
# Cursors -Default
# Do not group files and folder
# Не группировать файлы и папки
# FolderGroupBy -None
# Do not group files and folder in the Downloads folder
# Не группировать файлы и папки в папке Загрузки
FolderGroupBy -None
# Group files and folder by date modified (default value)
# Group files and folder by date modified in the Downloads folder (default value)
# Группировать файлы и папки по дате изменения (значение по умолчанию)
# FolderGroupBy -Default
# Do not expand to open folder on navigation pane (default value)
# Не разворачивать до открытой папки область навигации (значение по умолчанию)
NavigationPaneExpand -Disable
# Expand to open folder on navigation pane
# Развернуть до открытой папки область навигации
# NavigationPaneExpand -Enable
#endregion UI & Personalization
#region OneDrive

Loading…
Cancel
Save