views:

94

answers:

1

This is almost the same as http://stackoverflow.com/questions/101647/how-to-schedule-a-task-to-run-when-shutting-down-windows, except I need to do it programmatically. Also, I need the guarantee that when the script is run, no application can cancel the shutdown anymore.

Is this possible?

Thanks.

Update, with a little context: My company develops a sort of an antivirus program, designed to protect internet banking costumers. Naturally, this program is a frequent target of malware, so it needs to defend itself against being uninstalled. The first thing it does is inject itself into a system process, so that it can't be killed without bringing the whole system with it.

One of the typical ways of uninstalling such a program would be marking it for removal at the next shutdown, so our app actively monitors the registry keys which handle these postponed deletes and removes them.

I have recently been tasked with writing - oh the irony - an uninstaller for our app. The uninstaller must, of course, delete the files, so it has to work around everything we ourselves have built. It must be compatible with legacy versions, so changing the protection mechanisms is not an option.

+1  A: 

Since you need to support legacy versions that have no option of adding a backdoor for future use, you will likely have to boot the machine into an alternative OS so your files do not get loaded at bootup, then you can delete them safely. Look into incorporating a freeware third-party DOS clone, or even a small Linux version, into your uninstall process.

Remy Lebeau - TeamB