From 59e23667345d2b5fc003743439fd52ab4502c0f8 Mon Sep 17 00:00:00 2001 From: Dmitry Nefedov Date: Sat, 1 Apr 2023 15:14:15 +0300 Subject: [PATCH] Fixes for #466 and #472 --- .../Module/Sophia.psm1 | 6 +----- .../Module/Sophia.psm1 | 18 +++++++----------- .../Module/Sophia.psm1 | 6 +----- .../Module/Sophia.psm1 | 18 +++++++----------- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 7adb5eb6..94eba072 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -556,11 +556,7 @@ public static string GetString(uint strId) } # Check if Microsoft Edge as being a system component was removed by harmful tweakers - if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") - { - return - } - else + if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")) { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll 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 eba51bfd..a2aeb2e6 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 @@ -562,11 +562,7 @@ public static string GetString(uint strId) } # Check if Microsoft Edge as being a system component was removed by harmful tweakers - if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") - { - return - } - else + if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")) { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll @@ -630,6 +626,9 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() + # Import PowerShell 5.1 modules + Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell + # Display a warning message about whether a user has customized the preset file if ($Warning) { @@ -14960,8 +14959,7 @@ public static void PostMessage() $ToastXml.LoadXml($ToastTemplate.OuterXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) - # PowerShell 7.3 doesn't support yet using own caller app toast notifications. Fixed in PowerShell 7.4.0-preview.1 - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier().Show($ToastMessage) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage) # Telegram channel # Extract the localized "Open" string from shell32.dll @@ -14989,8 +14987,7 @@ public static void PostMessage() $ToastXml.LoadXml($ToastTemplate.OuterXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) - # PowerShell 7.3 doesn't support yet using own caller app toast notifications. Fixed in PowerShell 7.4.0-preview.1 - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier().Show($ToastMessage) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage) # Discord group # Extract the localized "Open" string from shell32.dll @@ -15018,8 +15015,7 @@ public static void PostMessage() $ToastXml.LoadXml($ToastTemplate.OuterXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) - # PowerShell 7.3 doesn't support yet using own caller app toast notifications. Fixed in PowerShell 7.4.0-preview.1 - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier().Show($ToastMessage) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage) #endregion Toast notifications # Check for UWP apps updates diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index 8101d403..f87a6e5a 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -610,11 +610,7 @@ public static string GetString(uint strId) } # Check if Microsoft Edge as being a system component was removed by harmful tweakers - if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") - { - return - } - else + if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")) { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll 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 a4cbf8ab..07817511 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 @@ -615,11 +615,7 @@ public static string GetString(uint strId) } # Check if Microsoft Edge as being a system component was removed by harmful tweakers - if (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") - { - return - } - else + if (-not (Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe")) { Write-Information -MessageData "" -InformationAction Continue # Extract the localized "Please wait..." string from shell32.dll @@ -683,6 +679,9 @@ public static string GetString(uint strId) # Save all opened folders in order to restore them after File Explorer restart $Script:OpenedFolders = {(New-Object -ComObject Shell.Application).Windows() | ForEach-Object -Process {$_.Document.Folder.Self.Path}}.Invoke() + # Import PowerShell 5.1 modules + Import-Module -Name Microsoft.PowerShell.Management, PackageManagement, Appx -UseWindowsPowerShell + # Display a warning message about whether a user has customized the preset file if ($Warning) { @@ -14390,8 +14389,7 @@ public static void PostMessage() $ToastXml.LoadXml($ToastTemplate.OuterXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) - # PowerShell 7.3 doesn't support yet using own caller app toast notifications. Fixed in PowerShell 7.4.0-preview.1 - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier().Show($ToastMessage) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage) # Telegram channel # Extract the localized "Open" string from shell32.dll @@ -14419,8 +14417,7 @@ public static void PostMessage() $ToastXml.LoadXml($ToastTemplate.OuterXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) - # PowerShell 7.3 doesn't support yet using own caller app toast notifications. Fixed in PowerShell 7.4.0-preview.1 - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier().Show($ToastMessage) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage) # Discord group # Extract the localized "Open" string from shell32.dll @@ -14448,8 +14445,7 @@ public static void PostMessage() $ToastXml.LoadXml($ToastTemplate.OuterXml) $ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML) - # PowerShell 7.3 doesn't support yet using own caller app toast notifications. Fixed in PowerShell 7.4.0-preview.1 - [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier().Show($ToastMessage) + [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Sophia").Show($ToastMessage) #endregion Toast notifications # Check for UWP apps updates