9

I am writing an application that updates some drivers. However the drivers are "in use" and can't be deleted unless I restart my computer.

So how can I write an application to delete these locked drivers without restarting the PC. IF Restarting MUST occur then how can I relaunch my application automatically when the computer restarts and delete those files?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Cocoa Dev
  • 9,361
  • 31
  • 109
  • 177
  • 3
    Incidentally, replacing drivers is one of the major reasons Windows still requires reboots. Now, some drivers don't seem to need them anymore (nVidia drivers don't prompt for a reboot, they just disable the display momentarily). – Powerlord May 24 '10 at 14:05
  • 2
    @R. Bemrose: If I understand correctly, this works by separating the driver up into a core that stays loaded and the actual meat of the driver, which can be unloaded and replaced. In other words, OP may not have any options. – Steven Sudit May 24 '10 at 14:07
  • Well they're printer drivers and printers aren't always in use. I learnt how to spooler service. – Cocoa Dev May 24 '10 at 14:19

2 Answers2

5

For Windows, you can "schedule" moving/deleting files around on a reboot by pinvoking the MoveFileEx API (Or the registry as described).

Alex K.
  • 171,639
  • 30
  • 264
  • 288
0

If you can disable the hardware that's using the drivers, this might allow the driver to be unloaded and replaced.

Dan Puzey
  • 33,626
  • 4
  • 73
  • 96
  • http://stackoverflow.com/questions/1438371/win32-api-function-to-programatically-enable-disable-device – Alex K. May 24 '10 at 19:52