简体   繁体   English

以管理员身份运行:访问用户VirtualStore

[英]Running as administrator: access user VirtualStore

I have an issue with my software installation / first time run on Vista / 7 in relation to the VirtualStore. 我的软件安装有问题/第一次在Vista / 7上相对于VirtualStore运行。

My software is written in C#. 我的软件是用C#编写的。 Installer: NSIS. 安装程序:NSIS。

  1. My application is installed using NSIS. 我的应用程序是使用NSIS安装的。 It runs as administrator 它以管理员身份运行
  2. After installation is finished, the user can immediately start the software from the installer. 安装完成后,用户可以立即从安装程序启动软件。
  3. This results in the first run of the program to be executed as admin. 这导致程序的第一次运行以admin身份执行。
  4. During the first run, a wizard has to be completed. 在第一次运行期间,必须完成一个向导。 This wizard will import data from an older version of the software, that is already on the computer (C:\\Program Files\\OldProgram\\Data) 该向导将从计算机上已经存在的较旧版本的软件(C:\\ Program Files \\ OldProgram \\ Data)中导入数据。
  5. However, on 7/Vista, this data is in the VirtualStore of the user. 但是,在7 / Vista上,此数据位于用户的VirtualStore中。 When I'm admin, I don't "see" this data and I can't convert it. 当我是管理员时,我不会“看到”此数据,也无法进行转换。

Questions: 问题:

  1. Can I know which user is currently logged in? 我可以知道哪个用户当前登录吗?
  2. Is there a generic way to access the Virtual Store of this user? 是否存在访问该用户虚拟商店的通用方法? Taking into account that the "Program Files" folder is named different is some countries and on 64-bits my app sits in "Program Files (x86)". 考虑到“ Program Files”文件夹的名称不同,某些国家/地区和我的应用程序以“ 64位”位于“ Program Files(x86)”中。
  1. UserInfo::GetName will give you the username, use UserMgr if you need more control UserInfo :: GetName将为您提供用户名,如果需要更多控制,请使用UserMgr
  2. Windows does not really provide a way to access another users special folders without their token, but this helper macro works in most cases. Windows并没有真正提供一种无需其他用户即可访问其他用户特殊文件夹的方式,但是该助手宏在大多数情况下都有效。 The name/location of the virtual store is not documented AFAIK so you have to get the closest special folder with GetUserShellFolderFromRegistry and then hardcode the VirtualStore part of the path... 虚拟商店的名称/位置未记录在AFAIK中,因此您必须使用GetUserShellFolderFromRegistry获取最近的特殊文件夹,然后对路径的VirtualStore部分进行硬编码...

If you want to launch a program as the user and not the administrator performing the install, use the UAC plugin (Or just remove the run checkbox on the finish page and let the user start the program normally) 如果要以用户身份启动程序而不是由管理员执行安装,请使用UAC插件 (或仅删除完成页面上的run复选框,然后让用户正常启动程序)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 任务正在运行,使用SYSTEM还是Administrator用户? - Task running-use SYSTEM or Administrator user? 将登录设置为管理员用户的模拟和运行服务是一回事吗? - Does Impersonation and running service with logon set to Administrator user is same thing? 以管理员身份在CMD中运行命令 - Running commands in CMD as administrator 管理员以用户身份验证 - Administrator Authenticate as User 在启动时以管理员身份运行程序 - Running Program as Administrator at Startup 如何从作为管理员用户运行的C#代码重新启动IIS? - How can I restart IIS from C# code running as a user who is an administrator? 检查当前用户是否为管理员 - Check if the current user is administrator 以管理员权限运行cmd命令 - Running cmd commands with Administrator rights 使用可执行文件的完整路径并以管理员身份运行时,Windows 10无法访问指定的设备,路径或文件 - Windows 10 cannot access the specified device, path, or file when using full path to executable, running as Administrator 任何用户/管理员都可以具有读/写访问权限的系统位置 - System location where any User/Administrator can have read/write access permission
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM