Browse Source

Fixed OneDrive function bug when explorer process doesn't load after restart

master
Dmitry Nefedov 2 months ago
parent
commit
cc3ac7baa8
  1. 36
      src/Sophia_Script_for_Windows_10/Module/Sophia.psm1
  2. 30
      src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1
  3. 30
      src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1
  4. 41
      src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1
  5. 36
      src/Sophia_Script_for_Windows_11/Module/Sophia.psm1
  6. 41
      src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

36
src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

@ -881,6 +881,7 @@ public static string GetIndirectString(string indirectString)
Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
@ -5391,10 +5392,12 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
# Do not restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force
# Attempt to unregister FileSyncShell64.dll and remove
@ -5416,10 +5419,9 @@ public static bool MarkFileDelete (string sourcefile)
}
}
Start-Sleep -Seconds 1
# Start the File Explorer process
# We need to wait for a few seconds to let explore launch unless it will fail to do so
Start-Process -FilePath explorer
Start-Sleep -Seconds 3
$Path = @(
$OneDriveFolder,
@ -5813,6 +5815,7 @@ function TempFolder
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5928,6 +5931,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
"Default"
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5959,6 +5963,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# Removing folders
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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)
@ -5994,6 +5999,7 @@ public static bool MarkFileDelete (string sourcefile)
try
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
}
catch
@ -6003,6 +6009,7 @@ public static bool MarkFileDelete (string sourcefile)
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$TempFolder = (Get-Item -Path $env:TEMP).FullName
$TempFolderCleanupTask = @"
Remove-Item -Path "$TempFolder" -Recurse -Force
@ -10445,6 +10452,7 @@ function InstallVCRedist
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10471,6 +10479,7 @@ function InstallVCRedist
Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
@ -10509,7 +10518,7 @@ function InstallDotNetRuntimes
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
ParameterSetName = "Runtimes"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
@ -10554,6 +10563,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10580,6 +10590,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10596,6 +10607,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10622,6 +10634,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10665,6 +10678,7 @@ function InstallDotNetRuntimes
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10681,6 +10695,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10707,6 +10722,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10724,6 +10740,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10750,6 +10767,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10766,6 +10784,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10792,6 +10811,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -16100,9 +16120,11 @@ public static void PostMessage()
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders

30
src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

@ -745,7 +745,7 @@ public static string GetIndirectString(string indirectString)
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Parameters = @{
TaskName = "SophiaTest"
TaskName = "SophiaTempScheduledTask"
Principal = $Principal
Action = $Action
Settings = $Settings
@ -765,9 +765,11 @@ public static string GetIndirectString(string indirectString)
exit
}
Unregister-ScheduledTask -TaskName SophiaTest -Confirm:$false -ErrorAction Ignore
# Remove temp schedule task
Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
@ -4452,6 +4454,7 @@ function TempFolder
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -4567,6 +4570,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
"Default"
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -4598,6 +4602,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# Removing folders
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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)
@ -4633,6 +4638,7 @@ public static bool MarkFileDelete (string sourcefile)
try
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
}
catch
@ -4642,6 +4648,7 @@ public static bool MarkFileDelete (string sourcefile)
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$TempFolder = (Get-Item -Path $env:TEMP).FullName
$TempFolderCleanupTask = @"
Remove-Item -Path "$TempFolder" -Recurse -Force
@ -8672,6 +8679,7 @@ function InstallVCRedist
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -8698,6 +8706,7 @@ function InstallVCRedist
Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
@ -8736,7 +8745,7 @@ function InstallDotNetRuntimes
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
ParameterSetName = "Runtimes"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
@ -8781,6 +8790,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -8807,6 +8817,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -8823,6 +8834,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -8849,6 +8861,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -8892,6 +8905,7 @@ function InstallDotNetRuntimes
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -8908,6 +8922,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -8934,6 +8949,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -8951,6 +8967,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -8977,6 +8994,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -8993,6 +9011,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9019,6 +9038,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -12333,9 +12353,11 @@ public static void PostMessage()
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders

30
src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

@ -745,7 +745,7 @@ public static string GetIndirectString(string indirectString)
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Parameters = @{
TaskName = "SophiaTest"
TaskName = "SophiaTempScheduledTask"
Principal = $Principal
Action = $Action
Settings = $Settings
@ -765,9 +765,11 @@ public static string GetIndirectString(string indirectString)
exit
}
Unregister-ScheduledTask -TaskName SophiaTest -Confirm:$false -ErrorAction Ignore
# Remove temp schedule task
Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
@ -4824,6 +4826,7 @@ function TempFolder
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -4939,6 +4942,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
"Default"
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -4970,6 +4974,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# Removing folders
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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)
@ -5005,6 +5010,7 @@ public static bool MarkFileDelete (string sourcefile)
try
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
}
catch
@ -5014,6 +5020,7 @@ public static bool MarkFileDelete (string sourcefile)
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$TempFolder = (Get-Item -Path $env:TEMP).FullName
$TempFolderCleanupTask = @"
Remove-Item -Path "$TempFolder" -Recurse -Force
@ -9299,6 +9306,7 @@ function InstallVCRedist
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9325,6 +9333,7 @@ function InstallVCRedist
Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
@ -9363,7 +9372,7 @@ function InstallDotNetRuntimes
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
ParameterSetName = "Runtimes"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
@ -9408,6 +9417,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9434,6 +9444,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -9450,6 +9461,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9476,6 +9488,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -9519,6 +9532,7 @@ function InstallDotNetRuntimes
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -9535,6 +9549,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9561,6 +9576,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -9578,6 +9594,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9604,6 +9621,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -9620,6 +9638,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9646,6 +9665,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -13540,9 +13560,11 @@ public static void PostMessage()
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders

41
src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

@ -843,7 +843,7 @@ public static string GetIndirectString(string indirectString)
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Parameters = @{
TaskName = "SophiaTest"
TaskName = "SophiaTempScheduledTask"
Principal = $Principal
Action = $Action
Settings = $Settings
@ -863,9 +863,11 @@ public static string GetIndirectString(string indirectString)
exit
}
Unregister-ScheduledTask -TaskName SophiaTest -Confirm:$false -ErrorAction Ignore
# Remove temp schedule task
Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
@ -5379,10 +5381,12 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
# Do not restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force
# Attempt to unregister FileSyncShell64.dll and remove
@ -5404,10 +5408,9 @@ public static bool MarkFileDelete (string sourcefile)
}
}
Start-Sleep -Seconds 1
# Start the File Explorer process
# We need to wait for a few seconds to let explore launch unless it will fail to do so
Start-Process -FilePath explorer
Start-Sleep -Seconds 3
$Path = @(
$OneDriveFolder,
@ -5801,6 +5804,7 @@ function TempFolder
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5916,6 +5920,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
"Default"
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5947,6 +5952,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# Removing folders
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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)
@ -5982,6 +5988,7 @@ public static bool MarkFileDelete (string sourcefile)
try
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
}
catch
@ -5991,6 +5998,7 @@ public static bool MarkFileDelete (string sourcefile)
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$TempFolder = (Get-Item -Path $env:TEMP).FullName
$TempFolderCleanupTask = @"
Remove-Item -Path "$TempFolder" -Recurse -Force
@ -10433,6 +10441,7 @@ function InstallVCRedist
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10459,6 +10468,7 @@ function InstallVCRedist
Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
@ -10497,7 +10507,7 @@ function InstallDotNetRuntimes
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
ParameterSetName = "Runtimes"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
@ -10542,6 +10552,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10568,6 +10579,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10584,6 +10596,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10610,6 +10623,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10653,6 +10667,7 @@ function InstallDotNetRuntimes
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10669,6 +10684,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10695,6 +10711,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10712,6 +10729,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10738,6 +10756,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10754,6 +10773,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10780,6 +10800,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -16108,9 +16129,11 @@ public static void PostMessage()
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders

36
src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

@ -857,6 +857,7 @@ public static string GetIndirectString(string indirectString)
Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
@ -4779,10 +4780,12 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
# Do not restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force
# Attempt to unregister FileSyncShell64.dll and remove
@ -4804,10 +4807,9 @@ public static bool MarkFileDelete (string sourcefile)
}
}
Start-Sleep -Seconds 1
# Start the File Explorer process
# We need to wait for a few seconds to let explore launch unless it will fail to do so
Start-Process -FilePath explorer
Start-Sleep -Seconds 3
$Path = @(
$OneDriveFolder,
@ -5201,6 +5203,7 @@ function TempFolder
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5316,6 +5319,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
"Default"
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5347,6 +5351,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# Removing folders
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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)
@ -5382,6 +5387,7 @@ public static bool MarkFileDelete (string sourcefile)
try
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
}
catch
@ -5391,6 +5397,7 @@ public static bool MarkFileDelete (string sourcefile)
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$TempFolder = (Get-Item -Path $env:TEMP).FullName
$TempFolderCleanupTask = @"
Remove-Item -Path "$TempFolder" -Recurse -Force
@ -9859,6 +9866,7 @@ function InstallVCRedist
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9885,6 +9893,7 @@ function InstallVCRedist
Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
@ -9968,6 +9977,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9994,6 +10004,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10010,6 +10021,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10036,6 +10048,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10079,6 +10092,7 @@ function InstallDotNetRuntimes
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10095,6 +10109,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10121,6 +10136,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10138,6 +10154,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10164,6 +10181,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10180,6 +10198,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10206,6 +10225,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10218,8 +10238,6 @@ function InstallDotNetRuntimes
}
}
<#
.SYNOPSIS
Bypass RKN restrictins using antizapret.prostovpn.org proxies
@ -15274,9 +15292,11 @@ public static void PostMessage()
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders

41
src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

@ -819,7 +819,7 @@ public static string GetIndirectString(string indirectString)
$Settings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable
$Principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -RunLevel Highest
$Parameters = @{
TaskName = "SophiaTest"
TaskName = "SophiaTempScheduledTask"
Principal = $Principal
Action = $Action
Settings = $Settings
@ -839,9 +839,11 @@ public static string GetIndirectString(string indirectString)
exit
}
Unregister-ScheduledTask -TaskName SophiaTest -Confirm:$false -ErrorAction Ignore
# Remove temp schedule task
Unregister-ScheduledTask -TaskName SophiaTempScheduledTask -Confirm:$false -ErrorAction Ignore
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\Computer.txt", "$env:TEMP\User.txt" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
# Save all opened folders in order to restore them after File Explorer restart
@ -4764,10 +4766,12 @@ public static bool MarkFileDelete (string sourcefile)
# Getting the OneDrive folder path and replacing quotes if exist
$OneDriveFolder = (Split-Path -Path (Split-Path -Path $OneDriveSetup[0] -Parent)) -replace '"', ""
# Terminate the File Explorer process
# Do not restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 0 -Force
Stop-Process -Name explorer -Force
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restart the File Explorer process automatically if it stops in order to unload libraries
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoRestartShell -PropertyType DWord -Value 1 -Force
# Attempt to unregister FileSyncShell64.dll and remove
@ -4789,10 +4793,9 @@ public static bool MarkFileDelete (string sourcefile)
}
}
Start-Sleep -Seconds 1
# Start the File Explorer process
# We need to wait for a few seconds to let explore launch unless it will fail to do so
Start-Process -FilePath explorer
Start-Sleep -Seconds 3
$Path = @(
$OneDriveFolder,
@ -5186,6 +5189,7 @@ function TempFolder
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:SystemDrive\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5301,6 +5305,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
"Default"
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
if ((Get-Item -Path $env:TEMP).FullName -eq "$env:LOCALAPPDATA\Temp")
{
Write-Information -MessageData "" -InformationAction Continue
@ -5332,6 +5337,7 @@ Unregister-ScheduledTask -TaskName SymbolicLink -Confirm:`$false
# Removing folders
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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)
@ -5367,6 +5373,7 @@ public static bool MarkFileDelete (string sourcefile)
try
{
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Remove-Item -Path $((Get-Item -Path $env:TEMP).FullName) -Recurse -Force -ErrorAction Stop
}
catch
@ -5376,6 +5383,7 @@ public static bool MarkFileDelete (string sourcefile)
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$TempFolder = (Get-Item -Path $env:TEMP).FullName
$TempFolderCleanupTask = @"
Remove-Item -Path "$TempFolder" -Recurse -Force
@ -9844,6 +9852,7 @@ function InstallVCRedist
winget install --id=Microsoft.VCRedist.2015+.x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9870,6 +9879,7 @@ function InstallVCRedist
Start-Process -FilePath "$DownloadsFolder\VC_redist.x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\VC_redist.x86.exe",
"$DownloadsFolder\VC_redist.x64.exe",
@ -9908,7 +9918,7 @@ function InstallDotNetRuntimes
(
[Parameter(
Mandatory = $false,
ParameterSetName = "Channels"
ParameterSetName = "Runtimes"
)]
[ValidateSet("NET6x86", "NET6x64", "NET7x86", "NET7x64", "NET8x86", "NET8x64")]
[string[]]
@ -9953,6 +9963,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -9979,6 +9990,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -9995,6 +10007,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.6 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10021,6 +10034,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10064,6 +10078,7 @@ function InstallDotNetRuntimes
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10080,6 +10095,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.7 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10106,6 +10122,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10123,6 +10140,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x86 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10149,6 +10167,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x86.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -10165,6 +10184,7 @@ function InstallDotNetRuntimes
winget install --id=Microsoft.DotNet.DesktopRuntime.8 --architecture x64 --exact --force --accept-source-agreements
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
Get-ChildItem -Path "$env:TEMP\WinGet" -Force -ErrorAction Ignore | Remove-Item -Recurse -Force -ErrorAction Ignore
}
else
@ -10191,6 +10211,7 @@ function InstallDotNetRuntimes
Start-Process -FilePath "$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe" -ArgumentList "/install /passive /norestart" -Wait
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
$Paths = @(
"$DownloadsFolder\dotnet-runtime-$LatestRelease-win-x64.exe",
"$env:TEMP\Microsoft_.NET_Runtime*.log"
@ -15277,9 +15298,11 @@ public static void PostMessage()
}
# PowerShell 5.1 (7.5 too) interprets 8.3 file name literally, if an environment variable contains a non-Latin word
# https://github.com/PowerShell/PowerShell/issues/21070
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
# Kill all explorer instances but only one in case enabled to launch folder windows in a separate process
Get-Process -Name explorer | Stop-Process -Force
Start-Sleep -Seconds 3
# Restoring closed folders

Loading…
Cancel
Save