From 2e089c404a3c7b66ebafdbebb72c7dd4b097838e Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Wed, 1 Feb 2023 19:41:35 +0300 Subject: [PATCH] Added new functions... --- Wrapper/Config/config_Windows_10.json | 34 +++ Wrapper/Config/config_Windows_10_LTSC.json | 34 +++ Wrapper/Config/config_Windows_11.json | 34 +++ .../de-DE/tooltip_Windows_10.json | 30 +++ .../de-DE/tooltip_Windows_11.json | 30 +++ .../en-US/tooltip_Windows_10.json | 30 +++ .../en-US/tooltip_Windows_11.json | 30 +++ .../ru-RU/tooltip_Windows_10.json | 30 +++ .../ru-RU/tooltip_Windows_11.json | 30 +++ Wrapper/SophiaScriptWrapper.exe | Bin 2396160 -> 2396672 bytes .../Module/Sophia.psm1 | 231 +++++++++++++---- src/Sophia_Script_for_Windows_10/Sophia.ps1 | 16 ++ .../Module/Sophia.psm1 | 231 +++++++++++++---- .../Sophia.ps1 | 16 ++ .../Module/Sophia.psm1 | 231 +++++++++++++---- .../Sophia.ps1 | 16 ++ .../Module/Sophia.psm1 | 235 +++++++++++++----- .../Sophia.ps1 | 16 ++ .../Module/Sophia.psm1 | 161 ++++++++---- src/Sophia_Script_for_Windows_11/Sophia.ps1 | 14 +- .../Module/Sophia.psm1 | 165 ++++++++---- .../Sophia.ps1 | 16 +- 22 files changed, 1301 insertions(+), 329 deletions(-) diff --git a/Wrapper/Config/config_Windows_10.json b/Wrapper/Config/config_Windows_10.json index d9fde1e6..92593f15 100644 --- a/Wrapper/Config/config_Windows_10.json +++ b/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", diff --git a/Wrapper/Config/config_Windows_10_LTSC.json b/Wrapper/Config/config_Windows_10_LTSC.json index 775948e3..98b1c550 100644 --- a/Wrapper/Config/config_Windows_10_LTSC.json +++ b/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", diff --git a/Wrapper/Config/config_Windows_11.json b/Wrapper/Config/config_Windows_11.json index cf6d8c44..4aabd1e0 100644 --- a/Wrapper/Config/config_Windows_11.json +++ b/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", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json b/Wrapper/Localizations/de-DE/tooltip_Windows_10.json index a7383ac9..8fb5438b 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_10.json +++ b/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", diff --git a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json b/Wrapper/Localizations/de-DE/tooltip_Windows_11.json index 0f518d72..962a2fb5 100644 --- a/Wrapper/Localizations/de-DE/tooltip_Windows_11.json +++ b/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", diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_10.json b/Wrapper/Localizations/en-US/tooltip_Windows_10.json index 193163f7..9fa9e15a 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_10.json +++ b/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", diff --git a/Wrapper/Localizations/en-US/tooltip_Windows_11.json b/Wrapper/Localizations/en-US/tooltip_Windows_11.json index 1ef14c37..956809f1 100644 --- a/Wrapper/Localizations/en-US/tooltip_Windows_11.json +++ b/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", diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json index c67dc4e1..f63919f5 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_10.json +++ b/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", diff --git a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json b/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json index 8aa557a1..70f33100 100644 --- a/Wrapper/Localizations/ru-RU/tooltip_Windows_11.json +++ b/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", diff --git a/Wrapper/SophiaScriptWrapper.exe b/Wrapper/SophiaScriptWrapper.exe index 04508e982262fdd6038e967934a1bac56b041987..c6121263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czRi0Oa)8_V9ERipY-;z*H@HOvh@uZ#R z;v}MK&@u1J;Xk;`BK88$2apgT%ii<{IA#f9acHc)G_Y{+aSb_X9NUDyw5yWaL0v z4iy&}IgD2EyGgufe6}b{Jw7Os8E+a`OSoeGCN?-Pu-{nGW`I~NOMABuY>*i@j5NYR-YBY z8M3O)OF@~!n1;gEZ#})=(6c5uz$n`9j?+(*@P1n4ExZ`?rg%z>p)?xv#Q@_o-Cd!4 zv8`jB&;a8%H@65i6er4<#jYW#jv2B=xNnHZicpi3$-QTU@*to_4jeqp&?Kd@Obtom zQ!HxaBZXN8nQ~X(r?CF5U=3W}DP>iwb)k%6TJ#cWdaC2=p+5A!(LDg-hta60jfX^9 z$YOQSkVtsgmXJ%N`acde7TfInL9f()AkrYNW>}S`|4LiDd?iAb6Dh0X|DzjE00l~JCYpd zi_gSyWxRM*T{{0TyQ62g`t0qIO!u?axELDZ(L%kzCiT%Q+&90AKCta29m)vi;1u->g(g1;(N!J@EZfMz~h0%0Z(vl@PpuqU~Z^WXk2Ku`q=Qu>_%$> zLhNq4na0opPi)dqiYF z{l(4~oB>xu*BRGb&r(m3uVtVpFehZ3r2V75NSN=8crEld95#1`GS)p^8AxmsS)(Hx zzV|#oaPXob^=B0=G@WhS>yx8-iDMO+?>Q8kIq_;`=0k==>rt7RX8Iec!DBOjqHkKs z|9yZf#zK0;eEKsrwetSVx~U8A&lG)2yOfSw`QwoKd)wWz$#TK#m+7CVPu-t+e!A +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 = @" @@ -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 diff --git a/src/Sophia_Script_for_Windows_10/Sophia.ps1 b/src/Sophia_Script_for_Windows_10/Sophia.ps1 index 75f7d6f0..d38706b8 100644 --- a/src/Sophia_Script_for_Windows_10/Sophia.ps1 +++ b/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 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 index f10b804e..dbc4c822 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1 @@ -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 = @" @@ -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 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 index 81eb2a94..9f508ff6 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2019/Sophia.ps1 +++ b/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 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 index 9f4a481b..63566ead 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1 @@ -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 = @" @@ -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 diff --git a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 index 20033b86..12a66857 100644 --- a/src/Sophia_Script_for_Windows_10_LTSC_2021/Sophia.ps1 +++ b/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 diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 index c13c82b3..b49d3df5 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1 @@ -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 = @" @@ -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 diff --git a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 index 4ee1f09b..f01234eb 100644 --- a/src/Sophia_Script_for_Windows_10_PowerShell_7/Sophia.ps1 +++ b/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 diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 9110e96b..ff4e09d3 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/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 = @" @@ -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 diff --git a/src/Sophia_Script_for_Windows_11/Sophia.ps1 b/src/Sophia_Script_for_Windows_11/Sophia.ps1 index 2edbc68b..20a8d485 100644 --- a/src/Sophia_Script_for_Windows_11/Sophia.ps1 +++ b/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 diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 index d7127213..987f5843 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1 @@ -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 = @" @@ -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 diff --git a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 index 7110b01a..9cd8fdd7 100644 --- a/src/Sophia_Script_for_Windows_11_PowerShell_7/Sophia.ps1 +++ b/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