|
|
@ -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 |
|
|
|