在Program Files文件夹绕过Windows权限限制 [英] Bypass Windows permission restrictions on program files folder

查看:1605
本文介绍了在Program Files文件夹绕过Windows权限限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了一个小的应用程序在C.它做一些文件操作,基本搜索,并改变一些文件名。但如果是在Win Vista / 7的应用在Program Files文件夹中的程序说权限被拒绝。反正有绕过这个?

I have made a small application in C. It does some file manipulation, basically searches and changes some files names. But if it is used in Win Vista/7 in the program files folder the program says permission denied. Is there anyway to bypass this?

另外,可以绕过Java的这种?

Also, can Java bypass this?

推荐答案

不要搭桥,使用应用程序数据目录中。

Don't bypass, use "Application Data" directory.

程序文件的目的是用于存储应用程序的运行过程中不改变文件。存储在那里的​​文件应该只安装/升级过程中被改变。

Program Files is intended to store files that do not change during run of application. Files stored there should be changed only during installation/update.

文件到应用程序运行(配置文件,设置等)过程中改变应存储应用程序数据目录中的用户文件夹中。

Files to be changed during application run (profiles, settings etc.) should be stored "Application Data" directory in users folder.

要获得路径使用的SHGetFolderPath 功能传:结果
CSIDL_APPDATA - 获得当前用户的应用程序数据目录结果
CSIDL_COMMON_APPDATA - 获得所有用户的应用程序数据目录结果
(最终) CSIDL_LOCAL_APPDATA - 获得当前用户,其目的是存储特定只有本地机器上的信息不能被转移到其它机器本地应用程序数据目录下,在反对为应用程序数据(也称为漫游应用程序数据),其中文件可以从一台机器可以自由移动到机器(例如你可以在$重新安装操作系统时pserve他们p $)。

To obtain the path use SHGetFolderPath function passing:
CSIDL_APPDATA - to obtain current user "Application Data" directory
CSIDL_COMMON_APPDATA - to obtain all users "Application Data" directory
(and eventually) CSIDL_LOCAL_APPDATA - to obtain current user "Local Application Data" directory which is intended to store informations specific only to local machine that cannot be moved to other machines, in opposition to "Application Data" (also called "Roaming Application Data") where files can be freely moved from machine to machine (i.e. you can preserve them during OS reinstallation).

如果您的应用程序就真的需要改变Program Files目录,然后请求权限的用户是你应该做的事情。你可以给你的应用程序的特殊清单所以它会试图获取管理员权限每次它的运行时间。您还可以获取即时的特权。

If your application do really need to alter Program Files directory then asking the user for permission is that what you should do. You can give your application special manifest so it'll try to obtain administrator rights every time it's run. You can also obtain privileges on-the-fly.

如果你正在写,几乎没有与操作系统干扰特定的应用程序,那么你可以创建一个服务(守护进程)。每次服务启动时,将获得服务注册过程中给予的特权。欲了解更多信息,请参阅DLL文件,进程和线程 - >服务MSDN上

If you are writing specific application that hardly interferes with the OS, then you can create a service (daemon). Every time the service is started it will obtain privileges given during service registration. For more information see "DLLs, Processes, and Threads -> Services" on MSDN

//编辑结果
您还可以轻松箱在.NET服务(C#是最适合的)。服务应用程序可以与用其他语言的客户端应用程序进行通信。但是,要注册服务,您将需要管理员权限。随着这类应用必须考虑所有安全问题。

// EDIT
You can also easily crate a service in .NET (C# is most suitable). Service application can communicate with client application written in other language. But to register a service you will need administrator rights. With this kind of application you must consider all security issues.

这篇关于在Program Files文件夹绕过Windows权限限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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