2
我想要在远程计算机上获取“CommonApplicationData”的路径。如何从远程机器获取CommonApplicationData?
这是本地版本
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
但我怎么是远程办?也许有一些WMI?
我想要在远程计算机上获取“CommonApplicationData”的路径。如何从远程机器获取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");
}
}