C#を使用してリモートマシンでPerforceを同期する必要があります

StackOverflow https://stackoverflow.com/questions/2366059

  •  23-09-2019
  •  | 
  •  

質問

こんにちは、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();

私はそれをすべてまとめる方法を理解することができません。どんな助けも大歓迎です。ありがとうございました

役に立ちましたか?

解決

私はそれを理解することができました:

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

    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top