我希望在远程计算机上获得“CommonApplicationData”的路径。
这是本地版
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
但我该怎么做呢?也许有一些WMI?
答案 0 :(得分:2)
完成了工作
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");
}
}