Join 3,557 readers in helping fund MetaFilter (Hide)

Tags:

How to remove 0b "Ghost Files" from Win7 Desktop?
November 24, 2011 2:55 PM   Subscribe

I need to remove various 0 byte "ghost files" from the desktops of a bunch of Windows 7 computers. I know DelinvFile works but is there a free alternative which actually works? I know it can also be done by turning off explorer.exe and going into cmd to delete them but what exactly are the steps for doing this? Any suggestions gratefully received.
posted by joannemullen to Computers & Internet (17 answers total)
 
Back when I ran windows had a virus problems I used a little application called Kill Box.

It should destroy anything that you need destroyed. Do keep in mind though that windows occasionally write protects files for a reason. Run a backup before you cause yourself grief.

Or to do things manually... To get to the command line I believe you hit F8 during start up, and choose the command line option. From there you can use the appropriate DOS commands. I'm not sure if the Windows cd lets you into a console, but it might?

Sorry my information is dated, but it should get you on the right track.
posted by Stagger Lee at 3:10 PM on November 24, 2011


The following batch file will clear out all zero-length files in the current directory:


set "filemask=*.*"
for %%A in (%filemask%) do if %%~zA==0 echo.del "%%A" >>removezerobytes.bat
removezerobytes
del removezerobytes


Just put that text into a file called something.bat, and then double click it.
posted by pompomtom at 3:14 PM on November 24, 2011 [1 favorite]


Thanks for the suggestion of Kill Box stagger lee. Unfortunately that only deletes files which are locked in use, rather than 0 byte files, so although it could see them on the desktop, it couldn't delete them. Getting into CMD isn't a problem by the way, just knowing exactly what to type when in there is. These aren't my computers and I don't want to risk causing havoc if I don't know exactly what I'm doing.

I tried your code pompomtom and though it seemed to run just fine, the files are still there. How do I make it clear out the current directory (i.e. desktop)?
posted by joannemullen at 3:55 PM on November 24, 2011


Is the batch file on the desktop? I've tested that on Win7 here, and it clears out my test files (though, that last line should read "del removezerobytes.bat" - oops).

Is it possible these files are being regenerated instantly?
posted by pompomtom at 4:05 PM on November 24, 2011


Another thought, if they're set to be read-only files, you could change the second line to:

for %%A in (%filemask%) do if %%~zA==0 echo.del /F "%%A" >>removezerobytes.bat

to ignore the read-only attribute.
posted by pompomtom at 4:10 PM on November 24, 2011


pompomtom, is there some reason you're doing filename collection and deletion in two separate passes?
for %%A in (*.*) do if %%~zA==0 del /f "%%~A"
should work just fine.

Joannemullen, simply opening a cmd window and typing in the above will fail for a couple of reasons (the current directory seen by the cmd console is unlikely to start off being the desktop, and the doubled percent signs used with "for" commands in batch files should be single for commands typed directly into the console).

What you should do is paste the command above into Notepad, save it onto your desktop as ghostbuster.cmd, and double-click it. When you launch a .cmd or .bat file with a double-click, it sees its containing folder as the current directory.

You might find that having done all of that, you still have visible desktop ghosts. These will most likely be in the All Users desktop (usually at C:\Users\Public\Desktop for Windows 7). You can copy and paste ghostbuster.cmd to that folder as well. You will probably need to exercise admin rights to do that, and you will probably also need to right-click the copy and choose Run As Administrator to let it do its job.
posted by flabdablet at 4:49 PM on November 24, 2011


pompomtom, is there some reason you're doing filename collection and deletion in two separate passes?

Voodoo.
posted by pompomtom at 5:00 PM on November 24, 2011


OK I tried both pompom's variations without success.

I also tried your code flabdeblet, ran it as an adminstrator and that didn't work either.

I was using notepad to turn pompom's code into a .bat file by the way, going into the cmd window thing was the way I'd deleted them before, but I can't remember how to do it.

As I guess I'm doing something wrong, I'll try them again.
posted by joannemullen at 5:03 PM on November 24, 2011


Really appreciate your help chaps.
posted by joannemullen at 5:09 PM on November 24, 2011


Have you tried rebooting after running those command lines? Those 0 byte files might a high-level refresh to "go away."

WhoLockMe says that it's a NT/Win2k/XP application, but it works in Win7. Install it, let it be context-menu accessible. Right click on the undeletable files; it'll tell you if anything (and what it is) has its claws in it, and an option to either remove those claws and/or delete the files.

I've also found that the take ownership script works for some things. Once owned, lots of random/weird stuff then becomes deletable.
posted by porpoise at 7:50 PM on November 24, 2011


Rebooting didn't help. The problem isn't that any process is locking them alas.
posted by joannemullen at 11:04 PM on November 24, 2011


Could you possibly right-click on one of the "ghost" files, select Properties, and post a screenshot showing the General tab from the resulting property sheet?
posted by flabdablet at 11:48 PM on November 24, 2011


I also tried your code flabdeblet, ran it as an adminstrator and that didn't work either.

Had you copied it into C:\Users\Public\Desktop before attempting to run it as administrator, and if so, are you sure the one you ran as administrator was indeed the C:\Users\Public\Desktop copy and not the C:\Users\joannemullen\Desktop copy?
posted by flabdablet at 11:51 PM on November 24, 2011


Being better with people than computers I persuaded the accountant to spring for a site licence for DelinvFile. As it was either that or die with a letter opener skewered into his intestines this very afternoon I think he made the wise choice. DelinvFile solved it in a second, but I'm sure it just automates your suggestions for ham fisted idiots like me. Just want to say thanks again for all your help boys, I'm sure everything you said was spot on so hopefully your kind advice will help someone else with a similar problem.
posted by joannemullen at 2:37 AM on November 25, 2011


Its possible the files are corrupted. Do a chkdsk, and try deleting them again.
posted by seanyboy at 2:37 AM on November 25, 2011


My suggestion would have been to start a cmd under SYSTEM (usually with 'at' or 'soon').
posted by rhizome at 12:45 PM on November 25, 2011


That used to work for XP, rhizome, but Vista and 7 don't allow the SYSTEM account to open an interactive console window.
posted by flabdablet at 5:32 PM on November 25, 2011


« Older What are the best indie/avant/...   |  I want to get my mom something... Newer »
This thread is closed to new comments.