Environment.CommandLine 속성

정의

이 프로세스에 대한 명령줄을 가져옵니다.

public:
 static property System::String ^ CommandLine { System::String ^ get(); };
public static string CommandLine { get; }
member this.CommandLine : string
Public Shared ReadOnly Property CommandLine As String

속성 값

String

명령줄 인수가 포함된 문자열입니다.

예제

다음 예제에서는 고유한 명령줄을 표시합니다.

using namespace System;

int main()
{
   Console::WriteLine();
   
   //  Invoke this sample with an arbitrary set of command line arguments.
   Console::WriteLine( "CommandLine: {0}", Environment::CommandLine );
}
/*
The example displays output like the following:

C:\>env0 ARBITRARY TEXT

CommandLine: env0 ARBITRARY TEXT
*/
using System;

class Example
{
    public static void Main()
    {
       Console.WriteLine();
       //  Invoke this sample with an arbitrary set of command line arguments.
       Console.WriteLine("CommandLine: {0}", Environment.CommandLine);
    }
}
// The example displays output like the following:
//       C:\>env0 ARBITRARY TEXT
//
//       CommandLine: env0 ARBITRARY TEXT
open System

//  Invoke this sample with an arbitrary set of command line arguments.
printfn $"\nCommandLine: {Environment.CommandLine}"
// The example displays output like the following:
//       C:\>env0 ARBITRARY TEXT
//
//       CommandLine: env0 ARBITRARY TEXT
Class Example
   Public Shared Sub Main()
      Console.WriteLine()
      '  Invoke this sample with an arbitrary set of command line arguments.
      Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
   End Sub 
End Class 
' The example displays output like the following:
'       C:\>CommandLine ARBITRARY TEXT
'       
'       CommandLine: CommandLine ARBITRARY TEXT

설명

이 속성은 현재 프로세스가 시작될 때 명령줄에 지정된 모든 인수 및 프로그램 이름에 대한 액세스를 제공합니다.

프로그램 이름에는 경로 정보가 포함될 수 있지만 그렇게 할 필요는 없습니다. 메서드를 GetCommandLineArgs 사용하여 문자열 배열에 구문 분석되고 저장된 명령줄 정보를 검색합니다.

명령줄 버퍼의 최대 크기는 특정 문자 수로 설정되지 않습니다. 컴퓨터에서 실행되는 Windows 운영 체제에 따라 달라집니다.

적용 대상

추가 정보