Skip to content

Commit 2db70b9

Browse files
committed
Improved SoftwareDistributionTask function
1 parent a6be6a6 commit 2db70b9

File tree

20 files changed

+49
-31
lines changed

20 files changed

+49
-31
lines changed

src/Sophia_Script_for_Windows_10/Module/Private/InitialActions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function InitialActions
123123
}
124124

125125
# https://github.com/PowerShell/PowerShell/issues/21070
126-
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127-
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
126+
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127+
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
128128
$Global:CompilerParameters.GenerateInMemory = $true
129129

130130
$Signature = @{

src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11415,9 +11415,11 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
1141511415
Start-Sleep -Seconds 600
1141611416
}
1141711417
11418-
# Run the task
11418+
# Wait until Windows Update service will stop
1141911419
(Get-Service -Name wuauserv).WaitForStatus("Stopped", "01:00:00")
1142011420
Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force
11421+
# Remove files which can be removed in a user scope only
11422+
Get-ChildItem -Path $env:SystemRoot\SoftwareDistribution\Download -Recurse | Remove-Item -Recurse
1142111423
1142211424
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
1142311425
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Private/InitialActions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function InitialActions
123123
}
124124

125125
# https://github.com/PowerShell/PowerShell/issues/21070
126-
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127-
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
126+
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127+
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
128128
$Global:CompilerParameters.GenerateInMemory = $true
129129

130130
$Signature = @{

src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8483,9 +8483,11 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
84838483
Start-Sleep -Seconds 600
84848484
}
84858485
8486-
# Run the task
8486+
# Wait until Windows Update service will stop
84878487
(Get-Service -Name wuauserv).WaitForStatus("Stopped", "01:00:00")
84888488
Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force
8489+
# Remove files which can be removed in a user scope only
8490+
Get-ChildItem -Path $env:SystemRoot\SoftwareDistribution\Download -Recurse | Remove-Item -Recurse
84898491
84908492
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
84918493
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Private/InitialActions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function InitialActions
123123
}
124124

125125
# https://github.com/PowerShell/PowerShell/issues/21070
126-
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127-
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
126+
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127+
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
128128
$Global:CompilerParameters.GenerateInMemory = $true
129129

130130
$Signature = @{

src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9606,9 +9606,11 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
96069606
Start-Sleep -Seconds 600
96079607
}
96089608
9609-
# Run the task
9609+
# Wait until Windows Update service will stop
96109610
(Get-Service -Name wuauserv).WaitForStatus("Stopped", "01:00:00")
96119611
Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force
9612+
# Remove files which can be removed in a user scope only
9613+
Get-ChildItem -Path $env:SystemRoot\SoftwareDistribution\Download -Recurse | Remove-Item -Recurse
96129614
96139615
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
96149616
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Private/InitialActions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ function InitialActions
160160
}
161161

162162
# https://github.com/PowerShell/PowerShell/issues/21070
163-
$Global:CompilerOptions = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
164-
$Global:CompilerOptions.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
163+
$Global:CompilerOptions = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
164+
$Global:CompilerOptions.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
165165
$Global:CompilerOptions.GenerateInMemory = $true
166166

167167
$Signature = @{

src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11425,9 +11425,11 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
1142511425
Start-Sleep -Seconds 600
1142611426
}
1142711427
11428-
# Run the task
11428+
# Wait until Windows Update service will stop
1142911429
(Get-Service -Name wuauserv).WaitForStatus("Stopped", "01:00:00")
1143011430
Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force
11431+
# Remove files which can be removed in a user scope only
11432+
Get-ChildItem -Path $env:SystemRoot\SoftwareDistribution\Download -Recurse | Remove-Item -Recurse
1143111433
1143211434
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
1143311435
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

src/Sophia_Script_for_Windows_11/Module/Private/InitialActions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function InitialActions
123123
}
124124

125125
# https://github.com/PowerShell/PowerShell/issues/21070
126-
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127-
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
126+
$Global:CompilerParameters = [System.CodeDom.Compiler.CompilerParameters]::new("System.dll")
127+
$Global:CompilerParameters.TempFiles = [System.CodeDom.Compiler.TempFileCollection]::new($env:TEMP, $false)
128128
$Global:CompilerParameters.GenerateInMemory = $true
129129

130130
$Signature = @{

src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10567,9 +10567,11 @@ while ([WinAPI.Focus]::GetFocusAssistState() -ne "OFF")
1056710567
Start-Sleep -Seconds 600
1056810568
}
1056910569
10570-
# Run the task
10570+
# Wait until Windows Update service will stop
1057110571
(Get-Service -Name wuauserv).WaitForStatus("Stopped", "01:00:00")
1057210572
Get-ChildItem -Path `$env:SystemRoot\SoftwareDistribution\Download -Recurse -Force | Remove-Item -Recurse -Force
10573+
# Remove files which can be removed in a user scope only
10574+
Get-ChildItem -Path $env:SystemRoot\SoftwareDistribution\Download -Recurse | Remove-Item -Recurse
1057310575
1057410576
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null
1057510577
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] | Out-Null

0 commit comments

Comments
 (0)