- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
首先,一些背景:
我们的产品需要通过在 NOTES.INI 文件中添加或更新一行来与 Lotus Notes 客户端集成。
如果我们正在处理 Notes 的单用户安装,我们不会遇到问题(即如果机器上有多个 Windows 用户,他们都将使用相同的 Notes 配置)。在这种情况下,Notes 安装目录中只有一个 NOTES.INI 文件。
但是,在 Notes 的多用户安装下(每个 Windows 用户都有自己的 Notes 配置),每个用户都有自己的 NOTES.INI 文件存储在用户的 LocalAppData 目录中 - 例如C:\Documents and Settings\用户名\Local Settings\Application Data\Lotus\Notes.
问题来了:如果我们的产品安装在多用户 Notes 客户端安装的机器上,我们需要能够更新该机器上每个用户的配置文件中的 NOTES.INI 文件。
我们可以通过在用户登录时运行一个程序来做到这一点,该程序检查该用户的 NOTES.INI 文件是否已更新,如果没有,则更新它。但是,我们应用程序的卸载过程需要能够为机器上的所有用户撤销这些修改。
因此问题来了:假设我们的代码以本地管理员权限运行,是否有某种方法可以遍历每个用户的配置文件并找到他们的 LocalAppData 目录,以便我们进行必要的更改?
非常感谢任何建议:-)
编辑 2009-03-25 16:52 GMT:
看起来我有一个可能的方法(感谢 Martin C):
For each subkey of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList: If it's a "real" user (determined somehow): Remember the subkey name - that's the user's SID Read the ProfileImagePath value If the user's Registry hive is not already loaded (i.e. there is no subkey of HKEY_USERS with the appropriate SID): Enable the SE_BACKUP_NAME and SE_RESTORE_NAME privileges Load the hive from ProfileImagePath\NtUser.dat using RegLoadKey Try to find the user's LocalAppData folder using each of the following Registry keys in turn: HKEY_USERS\<SID>\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders HKEY_USERS\<SID>\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders Expand environment variables in the resulting path if necessary (presumably just expanding %USERPROFILE% to the ProfileImagePath we got earlier) Use the path to find the user's NOTES.INI file and make the appropriate changes If we had to load the hive: Unload the hive using RegUnLoadKey
我或许可以将其编码,但它似乎有点脆弱,而且它可能有多种出错方式。谁有更“官方”的方法?
最佳答案
可以枚举的子键
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
每个子项都包含“ProfileImagePath”,它将指向配置文件的基本路径。根据操作系统版本和语言设置,您可以确定 LocalAppData 的位置(注意,它是语言相关的!)。
编辑: 更进一步的可能起点是
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
不幸的是,这可能因用户而异,而 HKEY_USERS 仅包含已加载配置文件的用户的 key 。您可以尝试是否可以以某种方式加载配置文件(如果用户注册表尚未加载到 HKEY_USERS,也许可以以某种方式附加用户注册表?)。
关于Windows:如何找到特定计算机上每个用户的 LocalAppData 目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/681572/
我正在为我的程序编写安装脚本,它应该在 Linux/Unix 操作系统上运行。以下文件的默认目录是什么: 可执行文件(程序)。程序应通过从命令行键入其名称来执行。 共享库。 第三方共享库(程序未开源,
我有一堆用户、组和应用程序注册,我的 MVC 应用程序使用 AAD 数据进行身份验证和授权。是否可以将 Azure Active Directory 从一个租户(目录)迁移到另一个租户(目录)?如果可
查看 cljsbuild 文档 https://github.com/emezeske/lein-cljsbuild :cljsbuild { :builds [{ ; The
忽略已经版本控制的文件 如果你不小心添加了一些应该被忽略的文件,你如何将它们从版本控制中去除而不会丢失它们?或许你有自己的IDE配置文件,不是项目的一部分,但将会花费很多时间使之按照自己的方式工作。
我想使用\tableofcontents 命令,但没有目录从新页面开始或在末尾创建新页面,并且所有内容都是单倍行距。我怎样才能做到这一点?我假设使用 tocloft,但有哪些选择? 谢谢 最佳答案 试
我有一些 javascript 菜单代码,可以在单独的目录中正常工作。但是,当我尝试从同一目录中调用相同的 .js 文件时,它不会看到这些文件。 以下内容来自另一个目录: script type="t
我有这样的路径: /my/path/to/important_folder 在同一级别上,我还有其他文件和文件夹想要在达到与 important_folder 相同的级别时列出。 我的文件夹可能更深,
1、获取文件路径实现 1.1 获取当前文件路径 ? 1
我正在使用最新版本的 NTEmacs。 我写了一个名为“.dir-locals.el”的文件,如下所示。 ((nil . ((tab-width . 8) (fill-column .
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
在我的 .vimrc 中有这些行 :set foldmethod=marker :set foldmarker=SECTION:,ENDSECTION: 用于自定义代码折叠。在我的文件中,相关语言的注
在 fish 中: for x in * echo $x end *这里包括所有目录和文件,如何只列出文件(或目录)? 最佳答案 fish 没有很多花哨的通配语法。但是,目录可以像这样迭代: f
这是我的目录结构: ├── src │ ├── helpers │ │ ├── __init__.py │ │ ├── foo.py │ │ └── bar.py │
我想递归重命名文件夹/目录名称并找到 this solution所以。但是这个命令没有效果 find . -type f -exec rename 's/old/new/' '{}' \; 这是一个正
我想在相册中创建一个文件夹,并希望将图像保存在创建的相册中。 这可能吗?有什么办法可以做到这一点吗? 我已经搜索过,大多数人都说这是不可能的。 感谢您的帮助。 最佳答案 您也许可以使用AssetsLi
如何在python中使用用户定义的名称创建临时文件/目录。我知道 tempfile .但是我看不到任何以文件名作为参数的函数。 注意:我需要这个来对包含临时文件的临时目录上的 glob(文件名模式匹配
我在项目中使用JaCoCo Gradle插件。 作为问题的一个示例,我的大部分代码都在com.me.mysoftware包下。 我正在使用代码生成器来生成build/generated/java/..
我正在尝试使用 Gradle 开始运行 jar 文件 我的任务如下所示: task startServer(type: Exec) { workingDir file("${buildDir}/a
如何在 Ant 中定义一个目录集,其中包括两个目录:项目的基目录和子目录“test”? 看起来您无法使用“/”、“.”或“”专门包含目录集的根目录。例如,这包括“./test”,但不包括“.”:
我正在使用 CTAGs 包,它使用 Sublime Text 2 生成两个文件 .tags 和 .tags_sorted_by_file。 那么当我进行项目搜索(CMD + SHIFT + F)时,如
我是一名优秀的程序员,十分优秀!