From c09f48143db7a26b998c97691346d5249f73d296 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sun, 6 Oct 2024 00:52:39 +0300 Subject: [PATCH] Fix for Show-Menu function --- Wrapper/Config/config_Windows_11_LTSC.json | 17 ---- .../Module/Sophia.psm1 | 8 +- .../Module/Sophia.psm1 | 8 +- .../Module/Sophia.psm1 | 8 +- .../Module/Sophia.psm1 | 8 +- .../Module/Sophia.psm1 | 8 +- .../Module/Sophia.psm1 | 79 ++----------------- .../Sophia.ps1 | 8 -- .../Module/Sophia.psm1 | 8 +- 9 files changed, 42 insertions(+), 110 deletions(-) diff --git a/Wrapper/Config/config_Windows_11_LTSC.json b/Wrapper/Config/config_Windows_11_LTSC.json index 8a38c6ea..2258c6af 100644 --- a/Wrapper/Config/config_Windows_11_LTSC.json +++ b/Wrapper/Config/config_Windows_11_LTSC.json @@ -645,23 +645,6 @@ "WindowsDefault": "One", "LTSC2024": "true" }, - { - "Region": "UI & Personalization", - "Control": "cmb", - "Required": "false", - "Function": "PreventTeamsInstallation", - "Arg": { - "Zero": { - "Tag": "Enable" - }, - "One": { - "Tag": "Disable" - } - }, - "Preset": "Zero", - "WindowsDefault": "One", - "LTSC2024": "true" - }, { "Region": "UI & Personalization", "Control": "cmb", diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 85aeb766..a00ce6ee 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -924,8 +924,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) 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 847e0ed7..2341ea25 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 @@ -892,8 +892,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) 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 a387f287..759b1263 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 @@ -892,8 +892,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) 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 c4b9088a..94213efe 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 @@ -928,8 +928,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 29f8e01a..0e603e6d 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -898,8 +898,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 index 71932462..2e961e96 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1 @@ -877,8 +877,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0) @@ -3376,77 +3380,6 @@ function TaskViewButton } } -<# - .SYNOPSIS - Chat (Microsoft Teams) installation for new users - - .PARAMETER Enable - Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users - - .PARAMETER Disable - Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users - - .EXAMPLE - PreventTeamsInstallation -Enable - - .EXAMPLE - PreventTeamsInstallation -Disable - - .NOTES - Current user -#> -function PreventTeamsInstallation -{ - param - ( - [Parameter( - Mandatory = $true, - ParameterSetName = "Enable" - )] - [switch] - $Enable, - - [Parameter( - Mandatory = $true, - ParameterSetName = "Disable" - )] - [switch] - $Disable - ) - - Clear-Variable -Name Task -ErrorAction Ignore - - switch ($PSCmdlet.ParameterSetName) - { - "Disable" - { - # Save string to run it as "NT SERVICE\TrustedInstaller" - # Prevent Microsoft Teams from installing for new users - $Task = "New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications -Name ConfigureChatAutoInstall -Value 0 -Type Dword -Force" - } - "Enable" - { - # Save string to run it as "NT SERVICE\TrustedInstaller" - # Remove block from installing Microsoft Teams for new users - $Task = "Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications -Name ConfigureChatAutoInstall -Value 1 -Type Dword -Force" - } - } - - # Create a Scheduled Task to run it as "NT SERVICE\TrustedInstaller" - $Parameters = @{ - TaskName = "BlockTeamsInstallation" - Action = New-ScheduledTaskAction -Execute powershell.exe -Argument "-WindowStyle Hidden -Command $Task" - } - Register-ScheduledTask @Parameters -Force - - $ScheduleService = New-Object -ComObject Schedule.Service - $ScheduleService.Connect() - $ScheduleService.GetFolder("\").GetTask("BlockTeamsInstallation").RunEx($null, 0, 0, "NT SERVICE\TrustedInstaller") - - # Remove temporary task - Unregister-ScheduledTask -TaskName BlockTeamsInstallation -Confirm:$false -} - <# .SYNOPSIS Seconds on the taskbar clock diff --git a/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 b/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 index d5da1417..d0956272 100644 --- a/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 +++ b/src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1 @@ -423,14 +423,6 @@ TaskViewButton -Hide # Отобразить кнопку "Представление задач" на панели задач (значение по умолчанию) # TaskViewButton -Show -# Hide the Chat icon (Microsoft Teams) on the taskbar and prevent Microsoft Teams from installing for new users -# Скрыть кнопку чата (Microsoft Teams) с панели задач и запретить установку Microsoft Teams для новых пользователей -PreventTeamsInstallation -Enable - -# Show the Chat icon (Microsoft Teams) on the taskbar and remove block from installing Microsoft Teams for new users (default value) -# Отобразить кнопку чата (Microsoft Teams) на панели задач и убрать блокировку на устанвоку Microsoft Teams для новых пользователей (значение по умолчанию) -# PreventTeamsInstallation -Disable - # Show seconds on the taskbar clock # Показывать секунды на часах на панели задач SecondsInSystemClock -Show 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 29c96df7..081dc4bb 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 @@ -902,8 +902,12 @@ public static extern bool SetForegroundWindow(IntPtr hWnd); $Menu += [WinAPI.GetStrings]::GetString(16956) } - # https://github.com/microsoft/terminal/issues/14992 - [System.Console]::BufferHeight += $Menu.Count + # Check if current terminal is Windows Terminal + if ($env:WT_SESSION) + { + # https://github.com/microsoft/terminal/issues/14992 + [System.Console]::BufferHeight += $Menu.Count + } $minY = [Console]::CursorTop $y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)