Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I am using Microsoft Visual studio 2013 and .net 4.5 to make an application for work. This program will have one exe file on a network drive. Every computer that has access will load from the same exe file including any remote desktop computers on any server and tablets that are remote desktop too.

What I would like to do is update this exe when needed by using file.copy(), this will copy the update and overwrite the old file. To do so I need every computer using the exe/application to close, if not I'll get "The process cannot access the file 'C:\progrm.exe' because it is being used by another process".

My boss suggested getting the device id of each computer that loaded the exe. I have looked this up and think I can get them but I don't know and can't find how to use the device ID to close the exe on each computer. This is one way of doing it, if anyone can point me in the right direction or even suggest other ways of doing this I would be greatly thankful.
Posted
Comments
Kornfeld Eliyahu Peter 18-Jan-15 7:58am    
Even you will be able to find all the 'clients' running your app and even will be able to close them it may be a bit dangerous, as your client may loose data...
Try to think of a solution where some loader will copy your exe to the client and run it from there, with an addition of some messaging that will notify client that new version has arrived...
Sergey Alexandrovich Kryukov 18-Jan-15 8:18am    
You are trying to become big abusers, with your "boss". :-)
The whole idea is bad. Don't to it. And it has nothing to do with client, server...
—SA

1 solution

There really isn't a "nice" way to do this: even if you keep a list of "running" instances, what happens if the computer dies, or the power fails, or ... ?

Instead, I'd have two applications, one of which runs on the server at all times, and which communicates with the "main" app (sockets or similar should do it) when it runs on the clients. When you want to upgrade, you tell the server app, and it talks to the clients and asks them to shut down. When they do, you can upgrade the file. If an app ends, or the socket dies because the PC is no longer on the network, the server app should be notified automatically.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900