windows 在没有管理员权限的情况下打开 UAC 时,程序可以写入磁盘的根目录吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5206673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can a program write to the root directory of a disk when UAC is turned on without having admin privileges?
提问by johny
If I am not an Administrator and start a program which writes to C:\ some textfile - will I need admin rights...in Windows 7 or Vista? I see in XP there are no problems to write to any folder including system32 - but I am not sure if a program in say .NET will be able to do that without admin permissions.
如果我不是管理员并启动了一个写入 C:\ 某个文本文件的程序 - 我是否需要管理员权限...在 Windows 7 或 Vista 中?我看到在 XP 中写入任何文件夹都没有问题,包括 system32 - 但我不确定 .NET 中的程序是否能够在没有管理员权限的情况下做到这一点。
回答by Erik
That depends on whether C:\ is a filesystem that supports permissions, and if so on the permissions set on the root directory, which can be modified by users with the correct privileges. Use GetTempPath()
for temporary files, or SHGetFolderPath
passing e.g. CSIDL_APPDATA
这取决于 C:\ 是否是支持权限的文件系统,如果是,则取决于在根目录上设置的权限,该权限可由具有正确权限的用户修改。使用GetTempPath()
临时文件,或SHGetFolderPath
通过如CSIDL_APPDATA
回答by Alexey Ivanov
No, you can't write to the root of disk even in Windows?XP if you are not an administrator. It's just everyone works as administrator in XP; and this assumption is actually wrong.
不,如果您不是管理员,即使在 Windows?XP 中也无法写入磁盘的根目录。只是每个人都在 XP 中以管理员身份工作;而这个假设实际上是错误的。
回答by Peter C
Yes. You won't be able to write to C:\Program Files\ or C:\Windows\, but just the root drive C:\ is fine.
是的。您将无法写入 C:\Program Files\ 或 C:\Windows\,但只有根驱动器 C:\ 可以。