ProcessStartInfo.ArgumentList プロパティ

定義

アプリケーションを起動するときに使用するコマンド ライン引数のコレクションを取得します。 リストに追加する文字列は、前もってエスケープする必要はありません。

public:
 property System::Collections::ObjectModel::Collection<System::String ^> ^ ArgumentList { System::Collections::ObjectModel::Collection<System::String ^> ^ get(); };
public System.Collections.ObjectModel.Collection<string> ArgumentList { get; }
member this.ArgumentList : System.Collections.ObjectModel.Collection<string>
Public ReadOnly Property ArgumentList As Collection(Of String)

プロパティ値

コマンド ライン引数のコレクション。

次の使用例は、プロセス開始情報に 3 つの引数を追加します。

var info = new System.Diagnostics.ProcessStartInfo("cmd.exe");
info.ArgumentList.Add("/c");
info.ArgumentList.Add("dir");
info.ArgumentList.Add(@"C:\Program Files\dotnet"); // there is no need to escape the space, the API takes care of it

// or if you prefer collection property initializer syntax:

var info = new System.Diagnostics.ProcessStartInfo("cmd.exe")
{
    ArgumentList = {
        "/c",
        "dir",
        @"C:\Program Files\dotnet"
    }
};

// The corresponding assignment to the Arguments property is:

var info = new System.Diagnostics.ProcessStartInfo("cmd.exe")
{
    Arguments = "/c dir \"C:\\Program Files\\dotnet\""
};
Dim info As New System.Diagnostics.ProcessStartInfo("cmd.exe")
info.ArgumentList.Add("/c")
info.ArgumentList.Add("dir")
info.ArgumentList.Add("C:\Program Files\dotnet")

' The corresponding assignment to the Arguments property is:

info.Arguments = "/c dir ""C:\Program Files\dotnet"""

注釈

ArgumentListArgumentsプロパティは互いに独立しており、同時に使用できるのはそのうちの 1 つだけです。 両方の API の主な違いは、ArgumentList指定された引数のエスケープを処理し、 を呼び出Process.Start(info)すときにオペレーティング システムに渡される 1 つの文字列を内部的に構築することです。 したがって、引数を適切にエスケープする方法がわからない場合は、 を選択ArgumentListArgumentsする必要があります。

重要

信頼されていないデータを指定してこのオブジェクトのインスタンスを使用することは、セキュリティ上のリスクが伴います。 このオブジェクトは信頼されたデータでのみ使用してください。 詳細については、「 すべての入力を検証する」を参照してください。

適用対象