rename running windows exe?

Thomas Heller thomas.heller at
Mon Oct 21 19:11:09 CEST 2002

Pete Shinners <pete at> writes:

> this falls heavily into a straight win32 question, but i'm trying to
> accomplish this under python, so i'm hoping there's an answer.
> i'm trying to write a simple script that will help me manage distribution
> of files on multiple platforms. i need a way to rename or move or delete an
> executable or dll that is running. perhaps it's a thing that windows will
> simply not allow.

No, it it not allowed at all.

> if not, is there a way i can find the offending processes and offer to send
> them a QUIT message? some simple dialog, "you need to close the following
> programs: notepad, shall i try to close them for you?"

This may open a can of worms: the program may have no windows open, so
the user cannot interact directly with it, the user may not have
sufficient access rights to do this, and so on.

The common technique AFAIK is describes by Jeff Richter in this

If this is not a persistent URL, you can probably find it by
googling for ReplaceFileOnReboot.
This technique is also used in the bdist_wininst uninstaller,
because it also allows a currently runing exe to remove itself.



More information about the Python-list mailing list