【发布时间】:2011-11-13 10:36:19
【问题描述】:
我想在远程机器上获取“CommonApplicationData”的路径。
这是本地版本
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
但是我该如何远程执行呢?也许有一些 WMI?
【问题讨论】:
标签: .net windows wmi remote-access
我想在远程机器上获取“CommonApplicationData”的路径。
这是本地版本
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
但是我该如何远程执行呢?也许有一些 WMI?
【问题讨论】:
标签: .net windows wmi remote-access
解决了
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");
}
}
【讨论】: