How to delete the running EXE file?

I ever meet a software can delete the running program files, and it didn’t
need to terminate the process first!!

I don’t know how it to do that, and I want it, How should I do?

Thanks!

Walker

Hello

Maybe something like this:

char * FileName = “c:\your\path\to\file.exe”;
char * TempFileName;
char * TempPath;
//allocate memory for TempFileName and TempPath here
GetTempPathA(x, TempPath);
GetTempFileNameA(TempPath, “ble”, NULL, TempFileName);
MoveFileExA(FileName,TempFileName, MOVEFILE_REPLACE_EXISTING);
MoveFileExA(TempFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);

Nicolas

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of WalkerNet
Sent: September 28, 2004 1:19 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to delete the running EXE file?

I ever meet a software can delete the running program files, and it didn’t
need to terminate the process first!!

I don’t know how it to do that, and I want it, How should I do?

Thanks!

Walker


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@eonmediainc.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thank you!

But, It is failure when I using the code to delete the
%SystemRoot%\Explorer.exe file, and the MoveFileEx immediately return FALSE.

If I want to delete the Explorer.exe, it’s possible? Have other way can do
it?

Thanks!

Walker

“Nicolas Sylvain” wrote in message
news:xxxxx@ntdev…
Hello

Maybe something like this:

char * FileName = “c:\your\path\to\file.exe”;
char * TempFileName;
char * TempPath;
//allocate memory for TempFileName and TempPath here
GetTempPathA(x, TempPath);
GetTempFileNameA(TempPath, “ble”, NULL, TempFileName);
MoveFileExA(FileName,TempFileName, MOVEFILE_REPLACE_EXISTING);
MoveFileExA(TempFileName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);

Nicolas

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of WalkerNet
Sent: September 28, 2004 1:19 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to delete the running EXE file?

I ever meet a software can delete the running program files, and it didn’t
need to terminate the process first!!

I don’t know how it to do that, and I want it, How should I do?

Thanks!

Walker


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@eonmediainc.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

hi, there are several ways to self delete an exe.

this is one http://www.codeguru.com/Cpp/W-P/win32/article.php/c4533/

but you didn’t say explorer.exe, well if it’s a system file you have
to be sure that the windows file protection is disabled.

Daniel