ProcessStartInfo.Arguments 속성

정의

애플리케이션을 시작할 때 사용할 명령줄 인수 집합을 가져오거나 설정합니다.

public:
 property System::String ^ Arguments { System::String ^ get(); void set(System::String ^ value); };
public string Arguments { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Arguments { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Arguments { get; set; }
[System.ComponentModel.SettingsBindable(true)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Arguments { get; set; }
[System.ComponentModel.SettingsBindable(true)]
public string Arguments { get; set; }
member this.Arguments : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Arguments : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Arguments : string with get, set
[<System.ComponentModel.SettingsBindable(true)>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.Arguments : string with get, set
[<System.ComponentModel.SettingsBindable(true)>]
member this.Arguments : string with get, set
Public Property Arguments As String

속성 값

FileName 속성에 지정된 대상 애플리케이션으로 전달할 인수를 포함한 단일 문자열입니다. 기본값은 빈 문자열("")입니다.

특성

예제

첫 번째 예제에서는 해당 인수를 콘솔에 에코하는 작은 애플리케이션(argsecho.exe)을 만듭니다. 두 번째 예제에서는 argsecho.exe 호출하여 속성에 대한 다양한 변형을 보여 주는 애플리케이션을 Arguments 만듭니다.

// Place this code into a console project called ArgsEcho to build the argsecho.exe target

using namespace System;

int main(array<System::String ^> ^args)
{
    Console::WriteLine("Received the following arguments:\n");

    for (int i = 0; i < args->Length; i++)
    {
        Console::WriteLine("[" + i + "] = " + args[i]);
    }

    Console::WriteLine("\nPress any key to exit");
    Console::ReadLine();
    return 0;
}
// Place this code into a console project called ArgsEcho to build the argsecho.exe target

using System;

namespace StartArgs
{
    class ArgsEcho
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Received the following arguments:\n");

            for (var i = 0; i < args.Length; i++)
            {
                Console.WriteLine($"[{i}] = {args[i]}");
            }

            Console.WriteLine("\nPress any key to exit");
            Console.ReadLine();
        }
    }
}
' Place this code into a console project called ArgsEcho to build the argsecho.exe target

Module Module1
    Sub Main()
        Dim i As Integer = 0

        For Each s As String In My.Application.CommandLineArgs
            Console.WriteLine($"[{i}] = {s}")
            i = i + 1
        Next

        Console.WriteLine(Environment.NewLine + "Press any key to exit")
        Console.ReadLine()
    End Sub
End Module
// Place the following code into a console project called StartArgsEcho. It depends on the
// console application named argsecho.exe.

using namespace System;
using namespace System::Diagnostics;

int main()
{
    ProcessStartInfo^ startInfo = gcnew ProcessStartInfo("argsecho.exe");
    startInfo->WindowStyle = ProcessWindowStyle::Normal;

    // Start with one argument.
    // Output of ArgsEcho:
    //  [0]=/a            
    startInfo->Arguments = "/a";
    Process::Start(startInfo);

    // Start with multiple arguments separated by spaces.
    // Output of ArgsEcho:
    //  [0] = /a
    //  [1] = /b
    //  [2] = c:\temp
    startInfo->Arguments = "/a /b c:\\temp";
    Process::Start(startInfo);

    // An argument with spaces inside quotes is interpreted as multiple arguments.
    // Output of ArgsEcho:
    //  [0] = /a
    //  [1] = literal string arg
    startInfo->Arguments = "/a \"literal string arg\"";
    Process::Start(startInfo);

    // An argument inside double quotes is interpreted as if the quote weren't there,
    // that is, as separate arguments. 
    // Output of ArgsEcho:
    //  [0] = /a
    //  [1] = /b:string
    //  [2] = in
    //  [3] = double
    //  [4] = quotes
    startInfo->Arguments = "/a /b:\"\"string in double quotes\"\"";
    Process::Start(startInfo);

    // Triple-escape quotation marks to include the character in the final argument received
    // by the target process.
    //  [0] = /a
    //  [1] = /b:"quoted string"
    startInfo->Arguments = "/a /b:\"\"\"quoted string\"\"\"";
    Process::Start(startInfo);

    return 0;
}
// Place this code into a console project called StartArgsEcho. It depends on the
// console application named argsecho.exe.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace StartArgsEcho
{
    class Program
    {
        static void Main()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("argsecho.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Normal;

            // Start with one argument.
            // Output of ArgsEcho:
            //  [0]=/a
            startInfo.Arguments = "/a";
            Process.Start(startInfo);

            // Start with multiple arguments separated by spaces.
            // Output of ArgsEcho:
            //  [0] = /a
            //  [1] = /b
            //  [2] = c:\temp
            startInfo.Arguments = "/a /b c:\\temp";
            Process.Start(startInfo);

            // An argument with spaces inside quotes is interpreted as multiple arguments.
            // Output of ArgsEcho:
            //  [0] = /a
            //  [1] = literal string arg
            startInfo.Arguments = "/a \"literal string arg\"";
            Process.Start(startInfo);

            // An argument inside double quotes is interpreted as if the quote weren't there,
            // that is, as separate arguments. Equivalent verbatim string is @"/a /b:""string with quotes"""
            // Output of ArgsEcho:
            //  [0] = /a
            //  [1] = /b:string
            //  [2] = in
            //  [3] = double
            //  [4] = quotes
            startInfo.Arguments = "/a /b:\"\"string in double quotes\"\"";
            Process.Start(startInfo);

            // Triple-escape quotation marks to include the character in the final argument received
            // by the target process. Equivalent verbatim string: @"/a /b:""""""quoted string""""""";
            //  [0] = /a
            //  [1] = /b:"quoted string"
            startInfo.Arguments = "/a /b:\"\"\"quoted string\"\"\"";
            Process.Start(startInfo);
        }
    }
}
' Place this code into a console project called StartArgsEcho. It depends on the
' console application named argsecho.exe.

Module Module1
    Sub Main()
        Dim startInfo As ProcessStartInfo = New ProcessStartInfo("argsecho.exe")
        startInfo.WindowStyle = ProcessWindowStyle.Normal

        ' Start with one argument.
        ' Output of ArgsEcho:
        '  [0]=/a            
        startInfo.Arguments = "/a"
        Process.Start(startInfo)

        ' Start with multiple arguments separated by spaces.
        ' Output of ArgsEcho:
        '  [0] = /a
        '  [1] = /b
        '  [2] = c:\temp
        startInfo.Arguments = "/a /b c:\temp"
        Process.Start(startInfo)

        ' An argument with spaces inside quotes is interpreted as multiple arguments.
        ' Output of ArgsEcho:
        '  [0] = /a
        '  [1] = literal string arg
        startInfo.Arguments = "/a ""literal string arg"" "
        Process.Start(startInfo)

        ' An argument inside double quotes is interpreted as if the quote weren't there,
        ' that is, as separate arguments.
        ' Output of ArgsEcho:
        '  [0] = /a
        '  [1] = /b:string
        '  [2] = in
        '  [3] = double
        '  [4] = quotes
        startInfo.Arguments = "/a /b:""""string in double quotes"""" "
        Process.Start(startInfo)

        ' Triple-escape quotation marks to include the character in the final argument received
        ' by the target process. 
        '  [0] = /a
        '  [1] = /b:"quoted string"
        startInfo.Arguments = "/a /b:""""""quoted string"""""" "
        Process.Start(startInfo)
    End Sub
End Module

설명

속성에 할당된 Arguments 문자열의 길이는 32,699보다 작아야 합니다.

인수가 대상 애플리케이션에서 분석 및 해석되므로 이 애플리케이션의 예상과 일치해야 합니다. 아래 예제에 설명된 대로 .NET 애플리케이션의 경우 공백은 여러 인수 간의 구분 기호로 해석됩니다. 공백이 포함된 단일 인수는 따옴표로 묶어야 하지만 따옴표 자체는 대상 애플리케이션으로 전달되지 않습니다. 마지막 구문 분석된 인수에 따옴표를 포함하려면 각 표시를 세 번 이스케이프합니다. 이 속성을 사용하여 명령줄 인수 ArgumentList 를 설정하는 경우 는 요소를 포함하지 않아야 합니다.

Arguments .NET Core 2.1 및 .NET Standard 2.1부터 지원되는 및 ArgumentList는 서로 독립적입니다. 즉, 속성에 할당된 문자열이 Arguments 컬렉션을 채웁니까 ArgumentList 컬렉션의 ArgumentList 멤버가 속성에 Arguments 할당되지 않습니다.

중요

신뢰할 수 없는 데이터로 이 개체의 인스턴스를 사용하는 것은 보안상 위험합니다. 신뢰할 수 있는 데이터로만 이 개체를 사용하세요. 자세한 내용은 모든 입력 유효성 검사를 참조하세요.

적용 대상