Celeb Glow
general | March 03, 2026

How to use SDelete to wipe out an entire directory and all its contents

I've downloaded the Microsoft Sys-internals SDelete to safely wipe out files from a laptop.

Based on the documentation and the help, the -s option allows to "Recurse subdirectories" and the -r to "remove read-only attribute". So I use it like this, from an administrator prompt:

sdelete -s -r c:\Users\guest\Documents

But I always get "Error deleting path/to/directory: The directory is not empty".

Is there a solution that does not involve calling a command for each subdirectory in the tree? I have also tried sdelete64 with the same result. I don't care about files that can't be deleted because they're in use or whatever, just as many as possible. Thank you.

0

3 Answers

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 -
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 ↓

enter image description here

5

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.

Use *
This worked for me:

  1. In PowerShell, change into directory cd SomeDir
  2. sdelete -s *
  3. cd ..
  4. remove-item -force -recurse SomeDir

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy