mirror of
https://github.com/zoicware/RemoveWindowsAI.git
synced 2026-03-20 01:26:18 +01:00
use runsapces for cbs store file removal
This commit is contained in:
@@ -2404,7 +2404,9 @@ function Remove-AI-Files {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($dir in $dirs) {
|
$jobs = foreach ($dir in $dirs) {
|
||||||
|
$rs = [powershell]::Create().AddScript({
|
||||||
|
param($path, $aiKeyWords)
|
||||||
Get-ChildItem $dir -Recurse -ErrorAction SilentlyContinue | Where-Object {
|
Get-ChildItem $dir -Recurse -ErrorAction SilentlyContinue | Where-Object {
|
||||||
$_.FullName -like "*$($aiKeyWords[0])*" -or
|
$_.FullName -like "*$($aiKeyWords[0])*" -or
|
||||||
$_.FullName -like "*$($aiKeyWords[1])*" -or
|
$_.FullName -like "*$($aiKeyWords[1])*" -or
|
||||||
@@ -2412,12 +2414,21 @@ function Remove-AI-Files {
|
|||||||
$_.FullName -like "*$($aiKeyWords[3])*" -or
|
$_.FullName -like "*$($aiKeyWords[3])*" -or
|
||||||
$_.FullName -like "*$($aiKeyWords[4])*" -and
|
$_.FullName -like "*$($aiKeyWords[4])*" -and
|
||||||
$(Test-Path $_.FullName -PathType Container) -eq $true
|
$(Test-Path $_.FullName -PathType Container) -eq $true
|
||||||
} | ForEach-Object {
|
}
|
||||||
#add paths to txt to delete with trusted installer
|
}).AddParameter('path', $path).AddParameter('aiKeyWords', $aiKeyWords)
|
||||||
Add-Content "$($tempDir)PathsToDelete.txt" -Value $_.FullName | Out-Null
|
|
||||||
|
[pscustomobject]@{
|
||||||
|
Runspace = $rs
|
||||||
|
Handle = $rs.BeginInvoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pathsToDelete = foreach ($job in $jobs) {
|
||||||
|
$job.Runspace.EndInvoke($job.Handle)
|
||||||
|
$job.Runspace.Dispose()
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-Content "$($tempDir)PathsToDelete.txt" -Value $pathsToDelete -Force | Out-Null
|
||||||
|
|
||||||
$command = "Get-Content `"$($tempDir)PathsToDelete.txt`" | ForEach-Object { Remove-Item `$_ -Force -Recurse -EA 0 }"
|
$command = "Get-Content `"$($tempDir)PathsToDelete.txt`" | ForEach-Object { Remove-Item `$_ -Force -Recurse -EA 0 }"
|
||||||
Run-Trusted -command $command -psversion $psversion
|
Run-Trusted -command $command -psversion $psversion
|
||||||
|
|||||||
Reference in New Issue
Block a user