我应该在客户的机器上安装我的应用程序? [英] which folder shall I install my application on customers' machines?

查看:54
本文介绍了我应该在客户的机器上安装我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想为标准用户设计我的应用程序(用C#编写),我将在客户的机器上安装我的应用程序?



如果我在Program Files文件夹上安装我的应用程序,它需要管理员权限....

If I want to design my application(written in C#) for Standard Users, which folder I shall install my application on customers' machines?

If I install my application on Program Files folder, it needs admin permission....

推荐答案

Southmountain写道:
Southmountain wrote:



两者都是。我想了解用户在Windows Vista上从安装到启动应用程序的过程。对于XP,我们没有问题,因为用户具有管理权限。


it is both. I want to understand the process from installation to starting my application by users on Windows Vista. For XP we do not have issue because user has administrative privilege.

好的,两者都有。安装选择是否请求以管理员身份运行,这是其中一个选项。如果它没有主动请求UAC,但在此过程中由于权限异常(当用户自愿以管理员身份启动时可能会或可能不会发生)而导致失败,则此安装是错误的。



有了应用程序本身,有两种选择。您可以拥有可以使用特权提升启动的应用程序,也可以不使用它。此类应用程序可能会或可能不会抛出权限异常,具体取决于用户实际执行的操作。通常,您在每个线程的堆栈帧之上(或在UI主事件周期中)捕获所有异常。因此,您可以处理它并建议用户以管理员身份运行。在已经启动的过程中提升权限是不可能的。因此,例如,当应用程序的第二个实例由第一个作为管理员启动时,我开发了一种特殊技术,传递请求以完成需要特殊权限的操作。当然,UAC会发出请求。除非用户完全切换UAC,否则无法避免,我不建议甚至不想讨论。



第二种方法是请求UAC从一开始。这是通过向应用程序添加应用程序清单并指定它来完成的。这篇MSDN文章对此进行了详细解释: http://msdn.microsoft.com/en-us/library /bb756929.aspx [ ^ ]。



-SA

All right, both. The installation chooses to request "Run as Administrator" or not, this is one of the options. If it does not request UAC by its initiative, but during the process there is a failure due to permission exception (which may or may not happen when the user voluntary starts it as administrator), this installation is wrong.

With the application itself, there are two options. You can have the application which can be started with elevation of privilege or without it. Such application may or may not throw permission exception, depending on what the user actually does. Normally, you catch all the exceptions on top of stack frame of each thread (or in UI main event cycle). So, you can handle it and advise the user to "Run As Administrator". It's impossible to elevate the permission in already started process. Therefore, I, for example, developed a special technique when the second instance of the application is started by the first on "As Administrator", passing the request to accomplish the action which needs special permissions. Naturally, UAC request will be issued. It is impossible to avoid unless the user switched UAC at all, which I don't recommend and don't even want to discuss.

The second approach is to request UAC from the very beginning. This is done by adding an application manifest to the application and specify it. This is fully explained in this MSDN article: http://msdn.microsoft.com/en-us/library/bb756929.aspx[^].

—SA


请参阅我对主题解决方案1的评论考虑安装。



你不应该决定你的应用程序是否进入某个目录。安装人员知道,因为他们与OS就安装的应用程序的标准路径进行协商。如果Windows针对x86,则为程序文件。如果Windows针对64位体系结构之一(x86-64,IE-64),如果应用程序针对相同的体系结构,则为Program Files,否则为Program Files(x86)(当应用程序针对x86,将由Windows通过WoW64执行。



请参阅:

https://en.wikipedia.org/wiki/Instruction_set [ ^ ],

https:// en .wikipedia.org / wiki / X86 [ ^ ] ,

https://en.wikipedia.org/wiki/X86-64 [ ^ ],

< a href =https://en.wikipedia.org/wiki/Itanium> https://en.wikipedia.org/wiki/Itanium [ ^ ],

https://en.wikipedia.org/wiki/WoW64 [ ^ ]。



许多应用程序搞乱了这个规则;并且它没有出现任何问题,尽管它从美学的角度来看,它完全令人作呕。



我会添加另一条规则:所有.NET针对任何CPU(主要和最好的,最纯粹的.NET模型)的产品也应该转到程序文件,但是一些安装程序将它们放在程序文件(x86)中,这不仅令人厌恶,而且还听起来很荒谬,因为这样的应用程序将运行为64位。但问题是:Windows Installer还没有教会尊重任何CPU,所以我想唯一的解决方案是创建两个或三个安装程序:x-86用于x-86操作系统和单独的安装程序用于x86-64(相同作为AMD64,甚至在Inter)和IE-64(与Itanium相同)。在其他方面,这些安装程序可以是相同的。



请注意,您永远不应该硬编码Program Files或Program Files(x86)。这些名称来自Windows安装程序的操作系统。



同样,任何体面的安装程序都应该提供指定自定义目录的选项,任何体面的应用程序都应该能够工作用它。不这样做是不可接受的。



最后,你应该考虑提供便携式产品,总是或可选的;最好的安装是没有安装。当然,并非总是可行。



-SA
Please see my comment to "Solution 1" for major consideration on installation.

You should not decide if your application goes to certain directory. The installers "know" that, because they negotiate with OS about standard path for installed application. If Windows is targeted to x86, this is "Program files". If Windows is targeted to one of the 64-bit architectures (x86-64, IE-64), this is "Program Files" if the application is targeted to the same architecture, and "Program Files (x86)" otherwise (when the application is targeted to x86 and will be executed by Windows via WoW64.

Please see:
https://en.wikipedia.org/wiki/Instruction_set[^],
https://en.wikipedia.org/wiki/X86[^],
https://en.wikipedia.org/wiki/X86-64[^],
https://en.wikipedia.org/wiki/Itanium[^],
https://en.wikipedia.org/wiki/WoW64[^].

Many application mess up this rule; and it does not present any problems despite the fact that it is, from the aesthetic point of view, it totally disgusting.

I would add another rule: all .NET products targeted to "Any CPU" (the main and the best, purest .NET model) should also go to "Program files", but some installers put them in "Program Files (x86)", and this is not only disgusting but also sounds ridiculous, as such application will run as 64 bit. But the problem here is: Windows Installer is not yet taught to respect "Any CPU", so I guess the only solution is to create two or three installers: x-86 for x-86 OS and separate installers for x86-64 (same as AMD64, even on Inter) and IE-64 (same as Itanium). In other respects, these installers can be identical.

Note that you never ever should hard-code "Program Files" or "Program Files (x86)". These names are taken from OS by the Windows Installer.

Again, any decent installer should provide the option to specify custom directory, and any decent application should be able to work with it. Failure to do so is unacceptable.

Finally, you should think of providing "portable" product, always or optionally; best installation is no installation. Of course, it is not always possible.

—SA


随时执行安装您将需要某种权限,通常是管理权限,如果您的安装程序或EXE未签名,则尤其如此。我的建议是遵循Microsoft已经规定的模式并使用 Program Files 文件夹。具有安装权限的用户可以访问此处。如果您尝试在其他任何地方安装,您很可能会遇到更大的权限问题,例如根驱动器或系统文件夹。像桌面或用户的下载文件夹这样的位置可以让用户轻松删除您的应用程序。
Anytime you perform an installation you will need some sort of permissions, typically administrative, and this is especially true if your installer or EXE isn't signed. My recommendation is to to follow the pattern Microsoft has laid out and use the Program Files folder. A user with the rights to install will have access here. If you try to install anywhere else, you will most likely run into even bigger permission issues, like the root drive or the system folder. Locations like the Desktop or the user's Downloads folder opens you up to the user easily deleting your application.


这篇关于我应该在客户的机器上安装我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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