0

こんにちは、C# を使用してプログラムで別のサーバーから自分のビルド サーバーで perforce を同期できるようにしたいと考えています。サーバー A には EXE があります。サーバー B にはパーフォースがあります。

私は両方のマシンで管理者権限を持っています。

次のようなものを使用したい

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

私はコンピュータの接続を持っています

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

scope.Connect();

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

4

1 に答える 1

0

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

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

    }
于 2010-03-02T21:14:20.637 に答える