diff --git a/Misc/Microsoft.HEVCVideoExtension_2.0.51121.0_x64__8wekyb3d8bbwe.Appx b/Misc/Microsoft.HEVCVideoExtension_2.0.51121.0_x64__8wekyb3d8bbwe.Appx deleted file mode 100644 index c06f9955..00000000 Binary files a/Misc/Microsoft.HEVCVideoExtension_2.0.51121.0_x64__8wekyb3d8bbwe.Appx and /dev/null differ diff --git a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 index 74992d1f..5c95e8f0 100644 --- a/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_10/Module/Sophia.psm1 @@ -4290,7 +4290,7 @@ function OneDrive # Get the OneDrive user folder path and remove it if it doesn't contain any user files if (Test-Path -Path $env:OneDrive) { - if ((Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object).Count -eq 0) + if ((Get-ChildItem -Path $env:OneDrive | Measure-Object).Count -eq 0) { Remove-Item -Path $env:OneDrive -Recurse -Force -ErrorAction Ignore @@ -4765,7 +4765,7 @@ function TempFolder # Cleaning up folders Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore - Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) { @@ -4805,12 +4805,12 @@ public static bool MarkFileDelete (string sourcefile) try { - Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop } catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } $SymbolicLinkTask = @" @@ -4927,7 +4927,7 @@ public static bool MarkFileDelete (string sourcefile) catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word @@ -9183,15 +9183,7 @@ function InstallDotNetRuntime6 Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait - <# - PowerShell 5.1 (7.2 too) interprets the 8.3 file name literally, if an environment variable contains a non-latin word, - so you won't be able to remove "$env:TEMP\Microsoft_Windows_Desktop_Runtime*.log" file explicitly - - Another ways to get normal path to %TEMP% - [Environment]::GetEnvironmentVariable("TEMP", "User") - (Get-ItemProperty -Path HKCU:\Environment -Name TEMP).TEMP - [System.IO.Path]::GetTempPath() - #> + # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word $Paths = @( "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe", "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe", @@ -11507,8 +11499,6 @@ while (`$true) { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11663,8 +11653,6 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11818,8 +11806,6 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -13808,9 +13794,6 @@ public static void PostMessage() } } - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning - # Persist Sophia notifications to prevent to immediately disappear from Action Center if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { @@ -13935,7 +13918,8 @@ public static void PostMessage() MeetNow -Hide } - Remove-Item -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore + # 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 @@ -13968,5 +13952,8 @@ function Errors } } | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim() } + + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning } #endregion Refresh Environment 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 1afe059d..d9415c38 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 @@ -3486,7 +3486,7 @@ function TempFolder # Cleaning up folders Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore - Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) { @@ -3526,12 +3526,12 @@ public static bool MarkFileDelete (string sourcefile) try { - Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop } catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } $SymbolicLinkTask = @" @@ -3648,7 +3648,7 @@ public static bool MarkFileDelete (string sourcefile) catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word @@ -7558,15 +7558,7 @@ function InstallDotNetRuntime6 Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait - <# - PowerShell 5.1 (7.2 too) interprets the 8.3 file name literally, if an environment variable contains a non-latin word, - so you won't be able to remove "$env:TEMP\Microsoft_Windows_Desktop_Runtime*.log" file explicitly - - Another ways to get normal path to %TEMP% - [Environment]::GetEnvironmentVariable("TEMP", "User") - (Get-ItemProperty -Path HKCU:\Environment -Name TEMP).TEMP - [System.IO.Path]::GetTempPath() - #> + # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word $Paths = @( "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe", "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe", @@ -8155,8 +8147,6 @@ while (`$true) { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -8311,8 +8301,6 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -8466,8 +8454,6 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -10230,9 +10216,6 @@ public static void PostMessage() } } - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning - # Persist Sophia notifications to prevent to immediately disappear from Action Center if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { @@ -10357,7 +10340,8 @@ public static void PostMessage() MeetNow -Hide } - Remove-Item -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore + # 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 @@ -10390,5 +10374,8 @@ function Errors } } | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim() } + + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning } #endregion Refresh Environment 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 f12801f7..e6d2af14 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 @@ -3857,7 +3857,7 @@ function TempFolder # Cleaning up folders Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore - Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) { @@ -3897,12 +3897,12 @@ public static bool MarkFileDelete (string sourcefile) try { - Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop } catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } $SymbolicLinkTask = @" @@ -4019,7 +4019,7 @@ public static bool MarkFileDelete (string sourcefile) catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word @@ -9314,8 +9314,6 @@ while (`$true) { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -9470,8 +9468,6 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -9625,8 +9621,6 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11443,9 +11437,6 @@ public static void PostMessage() } } - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning - # Persist Sophia notifications to prevent to immediately disappear from Action Center if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { @@ -11570,7 +11561,8 @@ public static void PostMessage() MeetNow -Hide } - Remove-Item -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore + # 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 @@ -11603,5 +11595,8 @@ function Errors } } | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim() } + + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning } #endregion Refresh Environment 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 20b70643..c0a9dbbb 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 @@ -4294,7 +4294,7 @@ function OneDrive # Get the OneDrive user folder path and remove it if it doesn't contain any user files if (Test-Path -Path $env:OneDrive) { - if ((Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object).Count -eq 0) + if ((Get-ChildItem -Path $env:OneDrive | Measure-Object).Count -eq 0) { Remove-Item -Path $env:OneDrive -Recurse -Force -ErrorAction Ignore @@ -4772,7 +4772,7 @@ function TempFolder # Cleaning up folders Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore - Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) { @@ -4812,12 +4812,12 @@ public static bool MarkFileDelete (string sourcefile) try { - Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop } catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } $SymbolicLinkTask = @" @@ -4934,7 +4934,7 @@ public static bool MarkFileDelete (string sourcefile) catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word @@ -9191,15 +9191,7 @@ function InstallDotNetRuntime6 Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait - <# - PowerShell 5.1 (7.2 too) interprets the 8.3 file name literally, if an environment variable contains a non-latin word, - so you won't be able to remove "$env:TEMP\Microsoft_Windows_Desktop_Runtime*.log" file explicitly - - Another ways to get normal path to %TEMP% - [Environment]::GetEnvironmentVariable("TEMP", "User") - (Get-ItemProperty -Path HKCU:\Environment -Name TEMP).TEMP - [System.IO.Path]::GetTempPath() - #> + # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word $Paths = @( "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe", "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe", @@ -11535,8 +11527,6 @@ while (`$true) { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11691,8 +11681,6 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11846,8 +11834,6 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -13834,9 +13820,6 @@ public static void PostMessage() } } - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning - # Persist Sophia notifications to prevent to immediately disappear from Action Center if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { @@ -13961,7 +13944,8 @@ public static void PostMessage() MeetNow -Hide } - Remove-Item -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore + # 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 @@ -13994,5 +13978,8 @@ function Errors } } | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim() } + + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning } #endregion Refresh Environment diff --git a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 index bbf7a854..eccc70c5 100644 --- a/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 +++ b/src/Sophia_Script_for_Windows_11/Module/Sophia.psm1 @@ -3792,7 +3792,7 @@ public static bool MarkFileDelete (string sourcefile) } # If there are some files or folders left in %OneDrive% - if ((Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object).Count -ne 0) + if ((Get-ChildItem -Path $env:OneDrive -Force | Measure-Object).Count -ne 0) { if (-not ("WinAPI.DeleteFiles" -as [type])) { @@ -4223,7 +4223,7 @@ function TempFolder # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp") { - return ### + return } # Restart the Printer Spooler service (Spooler) @@ -4239,7 +4239,7 @@ function TempFolder # Cleaning up folders Remove-Item -Path $env:SystemRoot\Temp -Recurse -Force -ErrorAction Ignore - Get-Item -Path $env:TEMP -Force -ErrorAction Ignore | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore + Get-Item -Path $env:TEMP -Force | Where-Object -FilterScript {$_.LinkType -ne "SymbolicLink"} | Remove-Item -Recurse -Force -ErrorAction Ignore if (-not (Test-Path -Path $env:LOCALAPPDATA\Temp)) { @@ -4247,7 +4247,7 @@ function TempFolder } # If there are some files or folders left in %LOCALAPPDATA\Temp% - if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0) + if ((Get-ChildItem -Path $env:TEMP -Force | Measure-Object).Count -ne 0) { # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa # The system does not move the file until the operating system is restarted @@ -4279,12 +4279,12 @@ public static bool MarkFileDelete (string sourcefile) try { - Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop } catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } $SymbolicLinkTask = @" @@ -4363,7 +4363,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Ignore - if ((Get-ChildItem -Path $env:TEMP -Force -ErrorAction Ignore | Measure-Object).Count -ne 0) + if ((Get-ChildItem -Path $env:TEMP -Force | Measure-Object).Count -ne 0) { # https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefileexa # The system does not move the file until the operating system is restarted @@ -4401,7 +4401,7 @@ public static bool MarkFileDelete (string sourcefile) catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word @@ -8690,15 +8690,7 @@ function InstallDotNetRuntime6 Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait - <# - PowerShell 5.1 (7.2 too) interprets the 8.3 file name literally, if an environment variable contains a non-latin word, - so you won't be able to remove "$env:TEMP\Microsoft_Windows_Desktop_Runtime*.log" file explicitly - - Another ways to get normal path to %TEMP% - [Environment]::GetEnvironmentVariable("TEMP", "User") - (Get-ItemProperty -Path HKCU:\Environment -Name TEMP).TEMP - [System.IO.Path]::GetTempPath() - #> + # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word $Paths = @( "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe", "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe", @@ -10913,8 +10905,6 @@ while (`$true) { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11069,8 +11059,6 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11224,8 +11212,6 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -13212,9 +13198,6 @@ public static void PostMessage() } } - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning - # Persist Sophia notifications to prevent to immediately disappear from Action Center if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { @@ -13340,7 +13323,7 @@ public static void PostMessage() } # 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 | Remove-Item -Recurse -Force -ErrorAction Ignore + 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 @@ -13373,5 +13356,8 @@ function Errors } } | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim() } + + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning } #endregion Refresh Environment 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 95265c1e..8693ee9d 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 @@ -3768,7 +3768,7 @@ function OneDrive # Get the OneDrive user folder path and remove it if it doesn't contain any user files if (Test-Path -Path $env:OneDrive) { - if ((Get-ChildItem -Path $env:OneDrive -ErrorAction Ignore | Measure-Object).Count -eq 0) + if ((Get-ChildItem -Path $env:OneDrive | Measure-Object).Count -eq 0) { Remove-Item -Path $env:OneDrive -Recurse -Force -ErrorAction Ignore @@ -4286,12 +4286,12 @@ public static bool MarkFileDelete (string sourcefile) try { - Get-ChildItem -Path $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction Stop + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Stop } catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } $SymbolicLinkTask = @" @@ -4408,7 +4408,7 @@ public static bool MarkFileDelete (string sourcefile) catch { # If files are in use remove them at the next boot - Get-ChildItem -Path $env:TEMP -Recurse -Force -ErrorAction Ignore | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} + Get-ChildItem -Path $env:TEMP -Recurse -Force | ForEach-Object -Process {[WinAPI.DeleteFiles]::MarkFileDelete($_.FullName)} } # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word @@ -8698,15 +8698,7 @@ function InstallDotNetRuntime6 Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait - <# - PowerShell 5.1 (7.2 too) interprets the 8.3 file name literally, if an environment variable contains a non-latin word, - so you won't be able to remove "$env:TEMP\Microsoft_Windows_Desktop_Runtime*.log" file explicitly - - Another ways to get normal path to %TEMP% - [Environment]::GetEnvironmentVariable("TEMP", "User") - (Get-ItemProperty -Path HKCU:\Environment -Name TEMP).TEMP - [System.IO.Path]::GetTempPath() - #> + # PowerShell 5.1 (7.3 too) interprets 8.3 file name literally, if an environment variable contains a non-latin word $Paths = @( "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe", "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe", @@ -10941,8 +10933,6 @@ while (`$true) { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11097,8 +11087,6 @@ Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -For { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -11252,8 +11240,6 @@ Get-ChildItem -Path `$env:TEMP -Recurse -Force | Where-Object -FilterScript {`$_ { $ScheduleService.GetFolder("\").DeleteFolder("Sophia", $null) } - - Remove-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia, Registry::HKEY_CLASSES_ROOT\AppUserModelId\Sophia -Recurse -Force -ErrorAction Ignore } } } @@ -13239,9 +13225,6 @@ public static void PostMessage() } } - Write-Information -MessageData "" -InformationAction Continue - Write-Warning -Message $Localization.RestartWarning - # Persist Sophia notifications to prevent to immediately disappear from Action Center if (-not (Test-Path -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Sophia)) { @@ -13366,7 +13349,8 @@ public static void PostMessage() MeetNow -Hide } - Remove-Item -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore + # 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 @@ -13399,5 +13383,8 @@ function Errors } } | Sort-Object -Property Line | Format-Table -AutoSize -Wrap | Out-String).Trim() } + + Write-Information -MessageData "" -InformationAction Continue + Write-Warning -Message $Localization.RestartWarning } #endregion Refresh Environment