【问题标题】:I need help syncing perforce on a remote machine with c#我需要帮助在远程机器上使用 c# 同步 perforce
【发布时间】:2010-03-02 19:27:28
【问题描述】:

您好,我希望能够使用 C# 以编程方式在我的构建服务器上从另一台服务器同步 perforce。 服务器 A 上有 EXE。 服务器 B 具有 perforce。

我在两台机器上都有管理员权限。

我想使用类似的东西

System.Diagnostics.Process.Start("p4 sync", "\"" + path + @""" -f //release/production/...")

我有电脑连接

ManagementScope scope = new ManagementScope("\\\\" + computer_name + "\\root\\cimv2");

scope.Connect();

我无法弄清楚如何将它们组合在一起。 任何帮助将不胜感激。谢谢你

【问题讨论】:

    标签: c# perforce wmi-service


    【解决方案1】:

    我想通了:

    public static void perforce_sync()
        {
    
            string computer_name = @"server_name";
            ManagementScope scope = new ManagementScope("\\\\" + computer_name + "\\root\\cimv2");
            scope.Connect();
            ObjectGetOptions object_get_options = new ObjectGetOptions();
            ManagementPath management_path = new ManagementPath("Win32_Process");
            ManagementClass process_class = new ManagementClass(scope, management_path, object_get_options);
            ManagementBaseObject inparams = process_class.GetMethodParameters("create");
            inparams["CommandLine"] = @"p4 sync -f //release/...";
            ManagementBaseObject outparams = process_class.InvokeMethod("Create", inparams, null);
            Console.WriteLine("Creation of the process returned: " + outparams["returnValue"]);
            Console.WriteLine("Process ID: " + outparams["processId"]);
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 2013-07-11
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多