【问题标题】:How to get CommonApplicationData from a remote machine?如何从远程机器获取 CommonApplicationData?
【发布时间】:2011-11-13 10:36:19
【问题描述】:

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

这是本地版本

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

但是我该如何远程执行呢?也许有一些 WMI?

【问题讨论】:

    标签: .net windows wmi remote-access


    【解决方案1】:

    解决了

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 1970-01-01
      • 2013-02-02
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 2018-04-24
      相关资源
      最近更新 更多