1. Flag a file to be deleted

Hi All,

Does anyone know how to delete a locked file when Windows 2000/XP boots?
I have seen programs flag files to be deleted next time Windows boots up,
but I can’t seem to figure this out.

new topic     » topic index » view message » categorize

2. Re: Flag a file to be deleted

Eucoder wrote:

<snip>

> Hi Chris,
> Thanks for the response!
> The problem with that is the file will be locked before my program runs.
> There is a way to have Windows delete a file when booting up, but I am not
> sure how to do it on a WinXP/2000 machine. On Win 95/98/ME you could use
> WININIT.ini to do it.

I use a DOS program for this purpose, that is started by AUTOEXEC.BAT.
Works fine on Windows 98, but unfortunately I can't tell about Win
2000/XP.

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

3. Re: Flag a file to be deleted

Juergen Luethje wrote:
> 
> Eucoder wrote:
> 
> <snip>
> 
> > Hi Chris,
> > Thanks for the response!
> > The problem with that is the file will be locked before my program runs.
> > There is a way to have Windows delete a file when booting up, but I am not
> > sure how to do it on a WinXP/2000 machine. On Win 95/98/ME you could use
> > WININIT.ini to do it.
> 
> I use a DOS program for this purpose, that is started by AUTOEXEC.BAT.
> Works fine on Windows 98, but unfortunately I can't tell about Win
> 2000/XP.
2K/XP ignore autoecxec.bat (which I used). You can configure
it to scan for SET commands, but that would be of no use...
Now I just delete files like that manually, using either
the Win XP repair CD or Knoppix if the drive isn't NTFS(Does
the newer version support NTFS? Maby I should upgrade...).

> 
> Regards,
>    Juergen
> 
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: Flag a file to be deleted

=0D
E> Does anyone know how to delete a locked file when Windows 2000/XP boots?=

E> I have seen programs flag files to be deleted next time Windows boots up=
,
E> but I can=92t seem to figure this out.


Moving Files in Windows NT

Win32-based applications running on Windows NT should use MoveFileEx()
with the MOVEFILE_DELAY_UNTIL_REBOOT flag to move, replace, or delete
files and directories currently being used. The next time the system
is rebooted, the Windows NT bootup program will move, replace, or
delete the specified files and directories.

To move or replace a file or directory that is in use, an application
must specify both a source and destination path on the same volume
(for example, drive C:). If the destination path is an existing file,
it will be overwritten. If the destination path is an existing
directory, it will not be overwritten and both the source and
destination paths will remain unchanged. Here is an example call to
move or replace a file or move a directory:

   // Move szSrcFile to szDstFile next time system is rebooted
   MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);

To delete a file or directory, the application must set the
destination path to NULL. If the source path is a directory, it will
be removed only if it is empty. Note that if you must use MoveFileEx()
to remove files from a directory, you must reboot the computer before
you can call MoveFileEx() to remove the directory. Here is an example
of how to delete a file or empty a directory:

   // Delete szSrcFile next time system is rebooted
   MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);


>From http://support.microsoft.com/default.aspx/kb/140570/EN-US/

new topic     » goto parent     » topic index » view message » categorize

5. Re: Flag a file to be deleted

> Moving Files in Windows NT
> 
> Win32-based applications running on Windows NT should use MoveFileEx()
> with the MOVEFILE_DELAY_UNTIL_REBOOT flag to move, replace, or delete
> files and directories currently being used. The next time the system
> is rebooted, the Windows NT bootup program will move, replace, or
> delete the specified files and directories.
> 
> To move or replace a file or directory that is in use, an application
> must specify both a source and destination path on the same volume
> (for example, drive C:). If the destination path is an existing file,
> it will be overwritten. If the destination path is an existing
> directory, it will not be overwritten and both the source and
> destination paths will remain unchanged. Here is an example call to
> move or replace a file or move a directory:
> 
>    // Move szSrcFile to szDstFile next time system is rebooted
>    MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
> 
> To delete a file or directory, the application must set the
> destination path to NULL. If the source path is a directory, it will
> be removed only if it is empty. Note that if you must use MoveFileEx()
> to remove files from a directory, you must reboot the computer before
> you can call MoveFileEx() to remove the directory. Here is an example
> of how to delete a file or empty a directory:
> 
>    // Delete szSrcFile next time system is rebooted
>    MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
> 
> 
> >From <a
> >href="http://support.microsoft.com/default.aspx/kb/140570/EN-US/">http://support.microsoft.com/default.aspx/kb/140570/EN-US/</a>
> 
> 
Thanks!
That seems like what I need

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu