1

I created a small application which users launch through a desktop shortcut pointing to a network share. Whenever I recompile the app and want to move it to the network share to make it available, it is always locked by many users who are using it, understandably. What I don't get is that I can close all the handles (net file 1234 /close) and the users are unaffected, i.e. they can still work on the app. I then copy the new file and ask them to restart.

Is there a way to "cut off" programmatically the users from the network exe file once they have launched it, so that I don't have to manually close all of the handles every the time?

chris
  • 649
  • 7
  • 26
  • Have you already tried to deploy as a ClickOnce Application? http://msdn.microsoft.com/en-us/library/71baz9ah.aspx – David Sdot Aug 15 '13 at 11:22

1 Answers1

3

They'll be affected but the way the jitter works indeed makes it a bit unlikely that their program will crash. Crashes are likely when you use Reflection in your code or the user's machine is under memory pressure from other processes and the program executes code that has not been jitted. YMMV.

The proper deployment choice here is ClickOnce. That creates a local copy of the program on the user's machine. And it automatically sees your update when they restart.

A possible band-aid is renaming the executable. Which works because Windows puts a lock on the file content, not the directory entry. Which lets you copy the update with the same name. Any user that restarts the app will now get the new version. You'll eventually be able to delete the renamed file. But do favor ClickOnce first.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • 1
    ClickOnce is probably the best option in this scenario although it's not free of deployment issues itself. The biggest problem I've had with it when migrating existing apps to ClickOnce are apps (written by other people, BTW) that expect the program to be deployed in Program Files or to a specific directory. It also requires the developer(s) to use care in maintaining certificates and such. – jfrankcarr Aug 15 '13 at 11:56
  • I was scared away by ClickOnce because of the certs... I'll look at it again. Renaming doesn't seem to be working (file is in use). – chris Aug 16 '13 at 06:25