Windows中是否有一个未提升权限的用户具有写权限的共享文件夹? [英] Is there a shared folder in Windows to which non-elevated users have write access?

查看:119
本文介绍了Windows中是否有一个未提升权限的用户具有写权限的共享文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道commonappdata(所有用户)可以保存系统范围的应用程序设置,但是在Vista / 7下,未提升权限的用户无法写入该目录。

I know that commonappdata (All Users) can hold system-wide application settings, but under Vista/7 non-elevated users can't write to that directory.

是否存在用户之间共享的文件夹,并且任何非管理员用户都可以写入该文件夹?

Is there a folder which is shared among users and any non-admin user can write to it?

这就是为什么我需要这样做:
我的应用是由具有提升权限的Inno Setup安装程序安装在PF目录中。然后,当实际的非管理员用户运行该程序时,它将使用另一个非高架Inno Setup安装程序将其设置复制到用户的AppData目录中。卸载程序后(由具有管理员权限的系统级安装程序启动),我想从每个用户的AppData目录中卸载程序的文件。

Here is why I need this: My app is installed in PF directory by an Inno Setup installer with elevated rights. Then when the actual non-admin user runs the program, it copies its settings to the user's AppData directory using another non-elevated Inno Setup installer. Upon deinstalling the program (initiated by the system-wide installer with admin rights) I want to uninstall the program's files from each users' AppData directory.

我可以想到两个解决方案:
1.获取Windows用户列表并遍历其AppData目录(似乎太复杂了)
2.将卸载程序的路径存储在上述公共用户数据目录中。

I can think of two solutions: 1. Getting a list of Windows users and iterating through their AppData dirs (seems way too complicated) 2. Storing the paths to the uninstallers in the above mentioned common user data directory.

有什么想法吗?

谢谢!

推荐答案

Windows XP中的共享文档目录

"Shared Documents" Directory in Windows XP

C:\Documents and Settings\All Users\Documents

或者,

%ALLUSERSPROFILE%\Documents

Vista / 7中的相应目录

Corresponding directory in Vista/7

C:\Users\Public

或者,

%PUBLIC%\Documents

但是您真正想要的是,是<$的 KNOWNFOLDERID 值c $ c> FOLDERID_PublicDocuments (旧版 CSIDL_COMMON_DOCUMENTS )。 SHGetFolderPath 函数可以为您提供路径。

But what you are really looking for, is the KNOWNFOLDERID value of FOLDERID_PublicDocuments (legacy CSIDL_COMMON_DOCUMENTS). The SHGetFolderPath function can then get you the path.

或更简单的VBScript替代方法,但是我不确定这在OS版本之间是否可靠:

Or an easier VBScript alternative, but I'm not sure how reliable this is across OS versions:

Const CSIDL_COMMON_DOCUMENTS = &h2e 
Set oShell = CreateObject("Shell.Application")
Wscript.Echo oShell.Namespace(CSIDL_COMMON_DOCUMENTS).Self.Path

我认为 NameSpace 不接受特定的常量。因此,您可以使用 COMMONAPPDATA =& H23 ,然后使用其父级。但这不是很干净或国际化的:

I think NameSpace doesn't accept that particular constant. So you might be able to take COMMONAPPDATA = &H23 and then use its parent. But that's not very clean or internationalized:

Wscript.Echo oShell.NameSpace(&h23).ParentFolder.Self.Path & "\Documents"

但是由于您使用的是Inno Setup,因此您实际上应该使用{commondocs } Shell文件夹常量,并使其易于使用。

But since you are using Inno Setup, you should really be using the {commondocs} Shell Folder Constant and make it easy for yourself.

这篇关于Windows中是否有一个未提升权限的用户具有写权限的共享文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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