我想在远程计算机上获取“CommonApplicationData”的路径。

这是本地版本

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

但是我该怎么做呢?也许有一些WMI?

最佳答案

解决了

public static string GetCommonAppData(string machineName)
{
    var shellFoldersPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders";
    using (var remoteBaseKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machineName))
    using (var shellFolders = remoteBaseKey.OpenSubKey(shellFoldersPath))
    {
        return (string) shellFolders.GetValue("Common AppData");
    }
}

10-07 19:10