-1

Possible Duplicate:
How cancel shutdown from a windows service C#

I have windows service that should transfer file to nas storage, now the problem is that these files are very important and must not be interupted by windows shutdown or restart,

I want to do something looks like windows updating, when a user hit shut down while the service transfering files in queue, windows should wait until all files are transfered then performing shutdown or restart.

like in this image: http://www.7tutorials.com/files/img/ie9_uninstall/unie93.png

how to do this in c#.net?

Community
  • 1
  • 1
khaled jendi
  • 61
  • 2
  • 5

1 Answers1

1

If I remember correctly, there's a command line utility shutdown.exe. One of the command line arguments you can use it /abort. You could just call it at a high frequency I suppose. It's also relatively easy to make a full screen window that constantly "steals" focus and is "top level". It can't, however, stop you from accessing the lock screen.

That sounds like a terrible plan, however. That kind of behavior by a program is not really tolerable, unless it's only going to be you using it. I think a better solution might be to transfer the file under a different name, and then rename it when its completed. Don't destroy the original until the operation is confirmed completed. If that's not possible, then I encourage you to investigate other solutions. Good luck!

Brent
  • 4,153
  • 4
  • 30
  • 63