在远程计算机.NET openremotebasekey访问%APPDATA%计算机、NET、APPDATA、openremotebasekey

2023-09-06 22:41:41 作者:今天很烦躁

我试图访​​问用户的应用程序数据在远程计算机上。我需要的一切权利。我想这样的:

I am trying to access the "AppData" of a user on a remote computer. I have all the rights needed. I tried this:

r = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, MachineName)
r.OpenSubKey(SIDValue & "\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders")
AppData = r.GetValue("AppData")

事实上,它检索我自己的应用程序数据文件夹......遥远的计算机上的帐户实际上的SID值和我的是一样的(我是在一个域)。我不知道这是否就是为什么我让我自己的应用程序数据文件夹中的原因。

The fact is that it retrieves my own appdata folder...Actually the SID Value of the account on the distant computer and on mine is the same (I am under a domain). I don't know if it is the reason why I get my own appdata folder.

我该如何操作?

当我浏览HKEY_LOCAL_MACHINE,我管理浏览HKEY_USERS时有关于远程computer..But信息没有。

When I browse the HKEY_Local_Machine, I manage to have information about the remote computer..But not when browsing HKEY_USERS.

推荐答案

我发现自己的答案,谢谢... 对于那些有兴趣谁进如何做到这一点,这是我如何做的:

I found the answer myself, thanks... For those who are interested into how to do this, here is how I did:

通过HKLM浏览没给我好DATAS(在远程计算机上的那些),我只是关注SYSTEMROOT值是在HKLM \软件\微软\的Windows NT \ CURRENTVERSION。 检索应用程序数据是做到这一点的方法后:

As browsing through HKLM did give me the good datas (the ones on the remote computer), I just searched for the systemroot value which is in HKLM\Software\Microsoft\Windows NT\CurrentVersion. Retrieving the appdata is done that way after:

systemdrive = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, _
                                                           MachineName).OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion").GetValue("SystemRoot").ToString.Substring(0, 3)

那么,对于Windows XP:

Then, For Windows XP:

appdata = systemdrive & "Documents and Settings\" & username & "\Application Data"

有关Windows 7的:

For Windows 7:

appdata = systemdrive & "Users\" & username & "\AppData\Roaming"