Here's the code:
Remove-Item -Recurse -Force -Path "data/user-data" -Include @("Backups", "Cache", "CachedData", "GPUCache", "logs")
Remove-Item -Recurse -Force -Path "data/tmp"
curl.exe -L "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-archive" -o "stable.zip"
Get-ChildItem -Exclude @("data", "update.ps1", "stable.zip") | Remove-Item -Recurse -Force
Expand-Archive -Path "stable.zip" -DestinationPath .
Remove-Item -Path "stable.zip"
Pause
As you can see, it deletes a whole bunch of files. It works fine when all of the files are not in use, but it throws a ton of exceptions when the files are in use.
Is there a way that I can pause the script while the files are still in use, but resume it as soon as all of them are free?