: This, probably, will not work in Windows - you can't delete an EXE file which is running.
:
:
This works just fine on Windows 98. Don't know about NT or 2000 since I don't have access to those (and I wouldn't use XP if you paid me).
#include <stdio.h>
#include <dir.h>
#include <dos.h>
int main(int argc, char *argv[])
{
int i;
struct ffblk finfo;
printf("\nfile name: %s\n", argv[0]);
i = findfirst(argv[0], &finfo, 0);
if (!i)
{
i = remove(argv[0]);
if (!i)
printf("file removed\n");
else
printf("\nCan't remove file %s\n", argv[0]);
}
else
printf("\nCan't find file %s\n", argv[0]);
return(0);
}