Sdelete syntax error?

1

Does anyone know why I can't run sDelete to delete the free disk space on drive C? It works on drive D.

I have tried both versions 1.61 and 1.51 and both give the same results:

SDelete - Secure Delete v1.51
Copyright (C) 1999-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

SDelete is set for 1 pass.
Cleaning free space on D:: 2%

And when I try to run the exact same command on drive C: this is what happens:

SDelete - Secure Delete v1.51
Copyright (C) 1999-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

SDelete is set for 1 pass.
Cleaning free space on C:: 0%Could not create free-space cleanup file:
The filename, directory name or volume label syntax is incorrect.

I know about Cipher.exe, but I would like to get sDelete to work.

Fate Averruncus

Posted 2014-12-12T18:32:09.840

Reputation: 42

Answers

1

Assuming that you are already running the program as Administrator (as I was when I got this message).

If you take a look at the source code for sdelete (I found it here), you can see that it is trying to create a temp file to use in the zeroing process.

_stprintf( tempFileName, _T("%sSDELTEMP"), DrivePath );   
hTempFile = CreateFile( tempFileName, GENERIC_WRITE,    
                0, NULL, CREATE_NEW,    
                FILE_FLAG_NO_BUFFERING|FILE_FLAG_SEQUENTIAL_SCAN|   
                FILE_FLAG_DELETE_ON_CLOSE|FILE_ATTRIBUTE_HIDDEN, NULL );   

if( hTempFile == INVALID_HANDLE_VALUE ) {   

    _tprintf( _T("Could not create free-space cleanup file: "));   
    PrintWin32Error( GetLastError());   
    return FALSE;   
}   

In my case, the TEMP environment variable was set to "C:\Users\Username\AppData\Local\Temp\1", and that directory did not exist.

To check your environment variable for TEMP, open a CMD prompt and type SET TEMP. This will print out the value for this environment variable.

In my case, I was preparing the operating system as a golden image template. I had just cleaned out the Temp folder and was going to zero out and re-thin the C: drive. I recreated the missing directory and everything worked as expected.

flakshack

Posted 2014-12-12T18:32:09.840

Reputation: 281

0

This can be solved by running sdelete (or the Command Prompt you started it from) as administrator. Instead of double-clicking on the Command Prompt icon (cmd.exe), right click it and select "Run as Administrator".

Søren L. Fog

Posted 2014-12-12T18:32:09.840

Reputation: 11

This worked perfectly for me, thank you so much! – syntaxcollector – 2017-08-04T16:16:38.710

0

The error message can be confusing. For me, it was the temp directory that did not exist...

mkdir %temp%

did the trick

Joris

Posted 2014-12-12T18:32:09.840

Reputation: 11

This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill – 2017-01-19T09:59:09.143

Well, i don't really agree. Flakshak's answer is exact but pretty long.The action to resolve the issue is not exactly clear (especialy for an non native english speaker). I just wanted to point out that this simple command could fix this exact error message. Straight to the point. – Joris – 2017-01-19T13:32:47.527

OMG, while i was cleaning up my drive, i've actually deleted the temporary folder and this solved my problem. Why the ***** software does not create the folder by itself? Anyway - this was my solution to the problem. Thanks! – KoCMoHaBTa – 2018-09-16T14:45:59.680