How to use SDelete to wipe out an entire directory and all its contents
Solution 1:
There may be some read-only files or directories in the specified folder tree.
See if adding the -r
switch helps.
sdelete -s -r c:\Users\guest\Documents
If that doesn't help, post the entire output for further diagnosis.
Important Note
The command-line arguments listed at the Microsoft site is outdated.
Here are the latest command-line arguments. As of this post, the latest SDelete version is v2.02
SDelete v2.02 - Secure file delete
Copyright (C) 1999-2018 Mark Russinovich
Sysinternals - www.sysinternals.com
usage: sdelete [-p passes] [-r] [-s] [-q] <file or directory> [...]
sdelete [-p passes] [-z|-c [percent free]] <drive letter [...]>
sdelete [-p passes] [-z|-c] <physical disk number>
-c Clean free space. Specify an option amount of space
to leave free for use by a running system.
-p Specifies number of overwrite passes (default is 1)
-r Remove Read-Only attribute
-s Recurse subdirectories
-z Zero free space (good for virtual disk optimization)
-nobanner Do not display the startup banner and copyright message.
Outdated list of CL arguments ↓
Solution 2:
I gave up on using SDelete to directly wipe out a directory tree. Instead, I used the following approach to delete an entire user's data (after backup):
1 - Create a new local administrator user, without a Microsoft account (e.g. newadmin)
2 - Login as the other user (e.g. myuser) and sign-out (top left icon after clicking the start button)
3 - Login as newadmin again and on settings, select myuser and remove account, choosing to delete all data
4 - Pretty much all data is gone at this point, but to be thorough go to Windows Explorer and delete the entire "\Users\myuser" folder. Then empty the recycle bin.
5 - There should be now plenty of free space reported by Windows 10. We can now use sdelete to zero that free space which may contain data, as follows, through an administrator prompt:
sdelete64 -z c:
I left the default one pass, because it's sufficient for my needs and the disk is SSD anyway.
If you just want to delete a random folder then just perform the last step after standard Windows deletion.
By the way I noticed that on Windows 10, one can also go to "Settings > Recovery > Reset this PC" and along the wizard choose "Remove files and clean the drive" which is supposed to do a better job at erasing files when passing the PC along, than the standard reset.
Solution 3:
Use *
This worked for me:
- In PowerShell, change into directory
cd SomeDir
sdelete -s *
cd ..
remove-item -force -recurse SomeDir