0

I created an application in C# that is launched at login to keep track of software installed through thousands of computers. Maintenance is near impossible since the executable is launched from a network share and is often locked as expected.

The use of another executable file could solve this issue by looking into a xml file for a true/false boolean before accessing the main executable:

AccessManager.exe --> XML, if true --> main.exe
                           if false, exit!

But I would have then to create another project. Is there any way to avoid that?

EDIT : A database file (SQLite) is in the same folder as the main app.

  • Sure, why not. You'll however have to wait a while if somebody left the building leaving the program running. Or you could just rename the file, the lock is on the file data, not the directory entry. – Hans Passant Dec 04 '15 at 17:01
  • Renaming doesn't always work for some reasons. I've been able to delete it occasionally but can't put it back. Since computers are still pointing on it and there is some delay involved in completely releasing the file, there is still a shadow of this file on the share. –  Dec 04 '15 at 17:04
  • Well, don't delete, that can't work since that also deletes the file data and it is locked. If you can't diagnose "some reasons" then switching to ClickOnce deployment starts to look pretty good. – Hans Passant Dec 04 '15 at 17:19
  • Maybe I could use the accesmanager class as the main executable and put anything else in a DLL to ease the maintenance. I am not familiar with DLL though, could it work? –  Dec 04 '15 at 18:42

1 Answers1

1

Why not have a command script that copies the app to the user's appdata folder and then runs it from there? Then nobody ever has a lock on the executable and when you update it the users will get the newest version when they log in again.

BTW, if the user loses network when running from a network share.... Not good.

TheHans255
  • 2,059
  • 1
  • 19
  • 36
The Sharp Ninja
  • 1,041
  • 9
  • 18
  • It could a great idea but we the file would be locked when being copied. Since we have thousand of computers, it would take a few hours before all copies are done. The goal is to really keep the files (main exe and DB file) together –  Dec 04 '15 at 18:24
  • You could write a broker that gets installed on the user's computer the first time they log in (again to the appdata folder). The broker would call a service to get the executable (think WCF). The service would use a static byte array to hold the code to be transported. It would also use a filesystemwatcher that would update the byte array as necessary. This way, the ONLY time the program is locked is during a compile and copy, and the brief time it takes the service to load the byte array. – The Sharp Ninja Dec 04 '15 at 18:30