Specifically, does type nul > somefile overwrite the entire file on disk? I saw a batch script website recommend generating an FTP script on the fly and then "securely" erasing it with the command in title. Is there any merit to this?
3 Answers
What does “type nul > somefile” do to “somefile” in Windows?
First,
somefileis opened for writing – this automatically causes the file to be truncated to 0 bytes. The data still remains on disk, just marked as "free" in the bitmapThen the contents of
nulare written tosomefile– in this case, exactly zero bytes, since you cannot read anything fromnul. The old data is not overwritten.The file is closed.
I saw a batch script website recommend generating an FTP script on the fly and then "securely" erasing it with the command in title. Is there any merit to this?
It's not any more "secure" than del somefile. It doesn't even remove the data from disk.
To erase a file securely, use a wipe utility such as sdelete or Eraser. Although, is a FTP script actually worth secure-wiping?
5It 'might' overwrite the file with zeros, but even if it did, that's hardly a secure erase. You would be better off using SDelete for this if you can.
Deleting a file will not prevent third party utilities from un-deleting it again, however you can turn any file into a zero-byte file to destroy the file allocation chain like this:
TYPE nul > C:\examples\MyFile.txt
DEL C:\examples\MyFile.txt
Source half way down the page
4