Skip to content

Commit

Permalink
Fix for Show-Menu function
Browse files Browse the repository at this point in the history
  • Loading branch information
farag2 committed Oct 5, 2024
1 parent 8be277e commit c09f481
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 110 deletions.
17 changes: 0 additions & 17 deletions Wrapper/Config/config_Windows_11_LTSC.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
79 changes: 6 additions & 73 deletions src/Sophia_Script_for_Windows_11_LTSC_2024/Module/Sophia.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/Sophia_Script_for_Windows_11_LTSC_2024/Sophia.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c09f481

Please sign in to comment.