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");
}
}