I am automating an icon cache refresh, and I am seeing an interesting difference between TaskKill and Stop-Process. In general I prefer using native PowerShell over DOS command line stuff launched from PowerShell, so I would rather use Stop-Process -name:explorer over Start-Process TaskKill "/f /im explorer.exe" -NoNewWindow to stop Explorer.exe so that the DB files are no longer "in use" and can be deleted.
However, the former allows Explorer.exe to restart instantly, so the icon DB files I need to delete are still in use and I can't delete them. The latter truly kills Explorer.exe and I have to use Start-Process later. Is there a way to get the TaskKill behavior using Stop-Process, or is this a rare situation where the old school kludge is also the only way that works?