command line delete on reboot

Status
Not open for further replies.

Spike

Posts: 2,122   +0
I need to schedule the removal of a file on reboot for a batch script I'm writing, but each time I think of a term to google, it comes up with a million and one results on everything but.

DOes anybody here know how to do this from the command line (ie, WITHOUT the use of win32 GUI programs such as HJT.

Ideally (though perhaps not essential) the file should be deleted at the point where programs such as CHKDSK would normally run. The one thing I partularly DON'T want to do is use the registry to do it.
 
That's a fairly interesting list. I don't like it much, but if it's the only way, it's the only way - It won't hurt just this once I guess, though I would have thought that deleting a file that's in use is a fairly common thing to need to do.

What's happening is that a when a file locks up and can't be deleted, Obviously I want to delete it, but even if I rename the file it's still locked "in use".

The 2k resource kit had a solution for it (inuse.exe), but I can't find it now and don't know if it works on XP.

Still, If I have to do like the bad guys do, then so be it - untidy, but effective.
 
What about "autoexec.bat"?? You could write a batch script in that, although its never worked for me.
 
I could call a batch script from autoexec.bat just the same as win.ini or from the registry.

The trouble is, it's untidy, doesn't remove itself (and so requires further scripting (if minor) to remove it afterwards, and is generally a bit of a pain really.

What would be really useful would be to call the appropriate windows API from the script...

MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)

...but of course, nothing could be so easy. (that was sarcasm. lol)

In the end, after some googling, I found an appropriate CLI utility through google (dellater), and better still, it comes with its assembly source code (all hail Open Source and the public domain! :) Not that I can actually write assembly from scratch, but sometimes small, well commented scripts such as this are easy to manipulate, as a very limited understanding of program flow and syntax in genereal can go a long way). So, with a few very simple modifications to that source and the appropriate assembler, I was able to modify and compile the tool to act as I wanted, and so now I don't have a problem :)

http://www.diamondcs.com.au/index.php?page=dellater-source

Problem solved :)

All I have to do now is put it to a nasty use and I could call myself a script kiddy! lol I'm NOT going to do that though. It's a name I'd rather not earn.
 
Status
Not open for further replies.
Back