Tip: Use MoveFile and PendMoves to Move or Delete a File That is Always in Use

Files can’t be moved when they’re in use by the operating system or an application. If a file is constantly in use, you can schedule Windows Vista to move the file during startup using the MoveFile tool, which you can download for free.

Use MoveFile exactly like you would use the Move command. For example:

movefile file.txt test\file.txt

Movefile v1.0 - copies over an in-use file at boot time
Move successfully scheduled.

The file will not be moved immediately. However, the next time the computer is restarted, Windows will move the file. If you want to delete a file that is constantly in use (a common requirement for removing malicious software), provide "" as the destination. For example:

movefile file2.txt ""

Movefile v1.0 - copies over an in-use file at boot time
Move successfully scheduled.

The same download that includes MoveFile includes the PendMoves command, which displays moves and deletions that have been scheduled. You can simply run the command without parameters, as the following example demonstrates:

pendmoves

PendMove v1.1
Copyright (C) 2004 Mark Russinovich
Sysinternals - wwww.sysinternals.com
Source: C:\Users\User1\Documents\file.txt
Target: C:\Users\User1\Documents\dest\file.txt
Source: C:\Users\User1\Documents\file2.txt
Target: DELETE
Time of last update to pending moves key: 2/27/2008 10:08 AM

From the Microsoft Press book Windows Vista Resource Kit, Second Edition.

Looking for More Tips?

For more Windows Vista tips, visit the TechNet Magazine Windows Vista Tips page.

For more Tips on other products, visit the TechNet Magazine Tips index.