Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot run remove onedrive "cannot remove item" "access to path denied" #222

Open
vm666 opened this issue Dec 19, 2019 · 7 comments
Open

Comments

@vm666
Copy link

vm666 commented Dec 19, 2019

I followed all of the steps correctly and am using admin powershell, yet i get this set of errors everytime.

Remove-Item : Cannot remove item C:\WINDOWS\WinSxS\wow64_microsoft-windows-onedrive-setup_31bf3856ad364e35_10.0.18362.1
_none_01f25b79d7a97c4b\OneDriveSetup.exe: Access to the path 'OneDriveSetup.exe' is denied.
At C:\Users\SU\Downloads\Debloat-Windows-10-master\Debloat-Windows-10-master\scripts\remove-onedrive.ps1:61 char:5
+     Remove-Item -Recurse -Force $item.FullName
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (OneDriveSetup.exe:FileInfo) [Remove-Item], UnauthorizedAccessExceptio
   n
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Remove-Item : Cannot remove item
C:\WINDOWS\WinSxS\wow64_microsoft-windows-onedrive-setup_31bf3856ad364e35_10.0.18362.1_none_01f25b79d7a97c4b: The
directory is not empty.
At C:\Users\SU\Downloads\Debloat-Windows-10-master\Debloat-Windows-10-master\scripts\remove-onedrive.ps1:61 char:5
+     Remove-Item -Recurse -Force $item.FullName
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\WINDOWS\WinS...1f25b79d7a97c4b:DirectoryInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
@W4RH4WK
Copy link
Owner

W4RH4WK commented Jan 21, 2020

Sorry for the late reply. At this point it's pretty normal to get some errors. These scripts operate in a best-effort manner and may fail at some points.

Let me you know if you come up with a fix. Otherwise I'd say this error is safe to ignore.

@cbaldan
Copy link

cbaldan commented Jan 27, 2020

I faced this same issue, it's a timming thing.
When the uninstall script is just finished running, some of those files are still being used by Windows itself, probably finishing up some cleanup in the backend.

What I did was break the OneDrive script in 2 parts:
The first one does the uninstall and takes ownership of the files.
Then I run remove-default-apps.ps1
And the deletion is postponed to after the default apps are uninstalled, which gives time for the OneDrive to finish for good.

I tested using W10 1909 in a VM and it now works 100% of the time.
BTW @W4RH4WK I did one more fork of this project, but I actually did quite some work with it.

You might like some of the ideas:
https://github.com/cbaldan/Debloat-Windows-10

@cbaldan
Copy link

cbaldan commented Jan 31, 2020

I solved one more piece of the puzzle.

To successfully delete the leftovers, it's necessary to stop explorer.exe before deleting them.
Plus, for whatever reason, the $env:LOCALAPPDATA\Microsoft\OneDrive was not there a few times, so I added a test before deleting.

Stop-Process -name explorer
Start-Sleep -s 3

# Removing OneDrive leftovers
foreach ($directory in (Get-ChildItem "$env:WinDir\WinSxS\*onedrive*")) {
    Remove-Item -Recurse -Force $directory.FullName
}

$localUserOneDriveFolder = "$env:LOCALAPPDATA\Microsoft\OneDrive"
if (Test-Path $localUserOneDriveFolder) {
    Remove-Item -Recurse -Force  $localUserOneDriveFolder
}

@Daynicgg
Copy link

Man si te fijas cuando da error te pone la ruta de el archivo el cual no se elimino solo ingresa a esa ruta y eliminalo manualmente es lo que hice
y si no lo puedes eliminar descarga el IObit Unlocker te lo eliminara sin problemas
espero haber ayudado

@W4RH4WK
Copy link
Owner

W4RH4WK commented Aug 26, 2020

@Daynicgg Please stick to English. If that is not possible, please attach a Google Translated version of your messages.

@BrunoPuccio
Copy link

Man si te fijas cuando da error te pone la ruta de el archivo el cual no se elimino solo ingresa a esa ruta y eliminalo manualmente es lo que hice
y si no lo puedes eliminar descarga el IObit Unlocker te lo eliminara sin problemas
espero haber ayudado

he says that when the error appears, the location of the file is shown so simply go to that folder and delete it manually. If that doesn't work then try with " IObit Unlocker"

@vm666
Copy link
Author

vm666 commented Aug 29, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants