重命名运行的可执行文件(EXE) [英] Rename a running executable (exe) file

查看:616
本文介绍了重命名运行的可执行文件(EXE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在努力推动一次更新多个服务器和我的经理发现,有可能命名运行.exe文件。利用这些知识,他要重命名运行exe文件并复制了一个新版本的说,这样的exe文件运行的人,他们在内存foo.exe的副本都很好和任何人谁打开指向foo.exe的快捷方式将获得一个新副本更新应用。

We are trying to push updates to multiple servers at once and my manager has found that it is possible to rename running .exe file. Using that knowledge he wants to rename a running exe and copy over a new version of said exe such that anyone running their in memory copy of foo.exe are fine and anybody who opens a shortcut pointing to foo.exe will get a new copy with updates applied.

我想我需要澄清,他并不指望旧副本神奇地更新,他只是希望他们能够继续运行旧版本,直到他们再次打开exe文件,在这种情况下,它就会打开新的一个有旧的名字。

I guess I need to clarify, He doesn't expect the old copy to magically update, he just expects them to keep running the old copy until they open the exe again, in which case it will then open the new one that has the name of the old one.

它有时抛出一个异常,该文件是在对他的程序中使用,但如果他试图将其重命名在一个循环中,将最终获得成功。在我的机器我还没有能够得到它的工作,甚至在一个循环。

It sometimes throws an exception that the file is in use on his program but if he tries renaming it in a loop it will eventually succeed. On my machine I have yet to be able to get it to work even in a loop.

我的第一个和主要的问题是:这是以往任何时候都可以接受的做到这一点。如果重命名一个正在运行的可执行永远是一个有效的方案?

My first and main question is this: Is it ever acceptable to do this. Should renaming a running executable ever be a valid scenario?

其次,如果它是一个有效的方案,然后何以可靠地做到这一点?我们目前的想法是尝试了一堆用File.Move(C#)做一个重命名倍,如果它不工作,然后写出一个错误日志,因此它可以被人工处理。

Secondly, if it is a valid scenario then how could one reliably do this? Our current thoughts are try a bunch of times using File.Move (C#) to do a rename and if it doesn't work then write out to an error log so it can be handled manually.

推荐答案

这是飞机机械师和一个酒吧外科医生见面。机械师说,你知道,我们有基本相同的工作。我们把破碎的东西出来,并提出了新的,更好的部件。外科医生说:是的,但你不必保持飞机的飞行,你正在做修理!

An airplane mechanic and a surgeon meet in a bar. The mechanic says "you know, we have basically the same job. We take broken stuff out and put new, better parts in." The surgeon says "yeah, but you don't have to keep the plane flying as you're making the repairs!"

试图通过该应用程序运行时将文件移动到更新应用程序似乎试图解决飞行中的飞机大约是危险的。可能?当然。大大提高catestrophic崩溃的风险?是的。

Trying to update an application by moving files while the application is running seems about as dangerous as trying to fix an airplane in flight. Possible? Sure. Greatly increased risk of catestrophic crash? Yep.

如果您要更新的应用程序是一个托管应用程序,可以考虑使用 ClickOnce部署的。这样一来,下一次有人运行的应用程序,如果有可用的新版本,它会自动复制下来,并安装。这比试图乱用的应用程序,同时它仍在运行更加安全和愉快。

If the application you are updating is a managed application, consider using ClickOnce Deployment. That way, the next time someone runs the application, if there is a new version available it will be copied down and installed automatically. That's much more safe and pleasant than trying to mess with an application while its still running.

这篇关于重命名运行的可执行文件(EXE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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