关闭网络和/或服务器上的所有应用程序实例 [英] close all instances of application on network and/or server

查看:167
本文介绍了关闭网络和/或服务器上的所有应用程序实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Visual Studio 2013和.net 4.5来创建应用程序。该程序将在网络驱动器上有一个exe文件。每个有访问权限的计算机都将从同一个exe文件加载,包括任何服务器和远程桌面平板电脑上的任何远程桌面计算机。



我想做什么是在需要时使用file.copy()更新此exe,这将复制更新并覆盖旧文件。为此,我需要使用exe / application关闭的每台计算机,否则我会得到进程无法访问文件'C:\ progrm.exe',因为它正被另一个进程使用。



我的老板建议获取加载exe的每台计算机的设备ID。我已经看了这个,并认为我可以得到它们,但我不知道,也无法找到如何使用设备ID关闭每台计算机上的exe。这是一种方法,如果有人能指出我正确的方向,甚至建议其他方式这样做我会非常感激。

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.

推荐答案

真的这不是一个好的方法:即使你保留一个正在运行的实例列表,如果计算机死机或电源故障会发生什么,或者......?



相反,我有两个应用程序,其中一个应用程序始终在服务器上运行,并且当它在客户端上运行时与主应用程序(套接字或类似应用程序)进行通信。当您想升级时,您告诉服务器应用程序,它会与客户端通话并要求它们关闭。当他们这样做时,您可以升级该文件。如果应用程序结束,或者套接字因PC不再在网络上而死亡,则应自动通知服务器应用程序。
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.


这篇关于关闭网络和/或服务器上的所有应用程序实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆