需要访问“程序文件”文件夹 [英] Access to “Program Files” folder needed

查看:187
本文介绍了需要访问“程序文件”文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个经常遇到的问题,但是在查看几乎所有的资料后,我都没有找到答案。问题如下:

我写了一个更新工具,连接到服务器来检查应用程序的新版本,然后将新版本复制到clientmashine。所以模式如下:

客户端安装由我预先配置的特定应用程序的更新程序。所以基本上更新程序是在Program Files文件夹中的某个地方。然后更新程序启动,连接到我们的服务器,并获取最新版本,并安装到与更新程序安装完全相同的目录。所以客户端不知道有两个应用程序。更新程序和更新程序的主要应用程序。我希望你明白这个主意。



这就是为什么我需要访问Program Files文件夹。



我正在开发windows 7和该软件也运行在7上。



有没有办法确保updater是由管理员运行的。我需要管理员权限才能访问吗?还有什么因为它拒绝访问,即使我有管理员权限?有没有办法在代码中检查用户拥有什么权限?

解决方案

我会将检查器和更新器分成两个不同的应用。检查器可以像普通用户那样运行。当它检测到有更新时,它启动更新程序。对于更新程序,您有清单,指出它需要管理员权限 。这将导致用户被提示授予访问权限(假定启用了UAC)。

I ran into this quite often stated problem but even after looking up nearly every scource I didn’t get an aswer. Problem is as follows:

I wrote a little updater tool that connects to a server to check for new versions of an application and then copies the new version to the clientmashine. So the pattern is as follows:

Client installs the updater which is pre configured by me with a specific application. So basicly the updater is somewhere in the Program Files Folder. Then the updater is started, connects to our server and gets the newest version and installs it to the very same dir as the updater is installed. So the client doesn’t know there are two applications. the updater and the main application the updater is for. I hope you get the idea.

So this is why I need access to the Program Files folder.

I am developing under windows 7 and the software is to run on 7 as well.

Is there a way to make sure the updater is run by administrator. Do I need admin rights to access it? What else since it denies access even if I do have admin rights? Is there a way to check in code what rights a user has?

解决方案

I would split the checker and the updater into two different apps. The checker can run as the regular user. When it detects that there is an update, it launches the updater. For the updater you have a manifest that states that it needs admin rights. This will cause the user to be prompted to grant access (given that UAC is enabled).

这篇关于需要访问“程序文件”文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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