Process.StartInfo 속성

정의

ProcessStart() 메서드에 전달할 속성을 가져오거나 설정합니다.

public:
 property System::Diagnostics::ProcessStartInfo ^ StartInfo { System::Diagnostics::ProcessStartInfo ^ get(); void set(System::Diagnostics::ProcessStartInfo ^ value); };
public System.Diagnostics.ProcessStartInfo StartInfo { get; set; }
[System.ComponentModel.Browsable(false)]
public System.Diagnostics.ProcessStartInfo StartInfo { get; set; }
member this.StartInfo : System.Diagnostics.ProcessStartInfo with get, set
[<System.ComponentModel.Browsable(false)>]
member this.StartInfo : System.Diagnostics.ProcessStartInfo with get, set
Public Property StartInfo As ProcessStartInfo

속성 값

프로세스를 시작하는 데 사용된 데이터를 나타내는 ProcessStartInfo입니다. 이러한 인수에는 프로세스를 시작하는 데 사용된 실행 파일이나 문서 이름이 포함됩니다.

특성

예외

StartInfo를 지정하는 값이 null입니다.

.NET Core 및 .NET 5 이상만 해당: 메서드가 Start() 프로세스를 시작하는 데 사용되지 않았습니다.

예제

다음 예제에서는 를 실행할 파일, 해당 파일에서 수행된 작업 및 사용자 인터페이스를 표시해야 하는지 여부를 채웁니다 StartInfo . 추가 예제는 클래스의 ProcessStartInfo 속성에 대한 참조 페이지를 참조하세요.

#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

int main()
{
    Process^ myProcess = gcnew Process;

    try
    {
        myProcess->StartInfo->UseShellExecute = false;
        // You can start any process, HelloWorld is a do-nothing example.
        myProcess->StartInfo->FileName = "C:\\HelloWorld.exe";
        myProcess->StartInfo->CreateNoWindow = true;
        myProcess->Start();
        // This code assumes the process you are starting will terminate itself. 
        // Given that it is started without a window so you cannot terminate it 
        // on the desktop, it must terminate itself or you can do it programmatically
        // from this application using the Kill method.
    }
    catch ( Exception^ e ) 
    {
        Console::WriteLine( e->Message );
    }
}
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        public static void Main()
        {
            try
            {
                using (Process myProcess = new Process())
                {
                    myProcess.StartInfo.UseShellExecute = false;
                    // You can start any process, HelloWorld is a do-nothing example.
                    myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
                    myProcess.StartInfo.CreateNoWindow = true;
                    myProcess.Start();
                    // This code assumes the process you are starting will terminate itself.
                    // Given that it is started without a window so you cannot terminate it
                    // on the desktop, it must terminate itself or you can do it programmatically
                    // from this application using the Kill method.
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        Public Shared Sub Main()
            Try
                Using myProcess As New Process()

                    myProcess.StartInfo.UseShellExecute = False
                    ' You can start any process, HelloWorld is a do-nothing example.
                    myProcess.StartInfo.FileName = "C:\\HelloWorld.exe"
                    myProcess.StartInfo.CreateNoWindow = True
                    myProcess.Start()
                    ' This code assumes the process you are starting will terminate itself. 
                    ' Given that it is started without a window so you cannot terminate it 
                    ' on the desktop, it must terminate itself or you can do it programmatically
                    ' from this application using the Kill method.
                End Using
            Catch e As Exception
                Console.WriteLine((e.Message))
            End Try
        End Sub
    End Class
End Namespace

설명

StartInfo 는 프로세스를 시작하는 데 사용할 매개 변수 집합을 나타냅니다. 가 Start 호출되면 StartInfo 는 시작할 프로세스를 지정하는 데 사용됩니다. 설정 하는 데 필요한 StartInfo 유일한 멤버는 속성입니다 FileName . 속성을 지정하여 FileName 프로세스를 시작하는 것은 Windows 시작 메뉴의 실행 대화 상자에 정보를 입력하는 것과 비슷합니다. 따라서 속성은 FileName 실행 파일을 나타낼 필요가 없습니다. 확장에 연결 된 시스템에 설치 된 애플리케이션 파일 형식의 수 있습니다. 예를 들어 FileName 메모장과 같은 편집기에서 텍스트 파일을 연결한 경우 .txt 확장명이 있거나 Microsoft Word 같은 워드 프로세싱 도구와 .doc 파일을 연결한 경우 .doc 가질 수 있습니다. 마찬가지로 실행 대화 상자에서 .exe 확장명을 사용하거나 사용하지 않고 실행 파일 이름을 수락할 수 있는 것과 동일한 방식으로 .exe 확장명은 멤버에서 FileName 선택 사항입니다. 예를 들어 속성을 "Notepad.exe" 또는 "메모장"으로 설정할 FileName 수 있습니다.

설정 하 여 ClickOnce 애플리케이션을 시작할 수는 FileName 속성을 원래 애플리케이션 설치 위치 (예를 들어, 웹 주소). 하드 드라이브에 설치 된 위치를 지정 하 여 ClickOnce 애플리케이션을 시작 하지 않습니다.

파일 이름에 .doc 파일과 같이 실행할 수 없는 파일이 포함된 경우 파일에 대해 수행할 작업을 지정하는 동사를 포함할 수 있습니다. 예를 들어 .doc 확장명에서 끝나는 파일에 대해 를 "인쇄"로 설정할 Verb 수 있습니다. 속성에 대한 값을 Verb 수동으로 입력하는 경우 속성에 FileName 지정된 파일 이름에 확장명이 필요하지 않습니다. 그러나 속성을 사용하여 Verbs 사용할 수 있는 동사를 결정하는 경우 확장을 포함해야 합니다.

프로세스에서 StartInfo 메서드를 호출하는 시간까지 속성에 지정된 매개 변수를 Start 변경할 수 있습니다. 프로세스를 시작한 후에는 StartInfo 값을 변경해도 연결된 프로세스에 영향을 주거나 다시 시작하지 않습니다. 및 속성 집합을 Start(ProcessStartInfo) 사용하여 메서드를 ProcessStartInfo.UserName 호출하는 경우 관리 CreateProcessWithLogonW 되지 않는 함수가 호출되어 속성 값이 이거나 WindowStyle 속성 값 true 이 인 경우에도 CreateNoWindow 새 창에서 프로세스를 시작합니다Hidden.ProcessStartInfo.Password

메서드에서 반환 Start 된 개체의 StartInfoProcess 속성에만 액세스해야 합니다. 예를 들어 에서 반환GetProcesses된 개체의 StartInfo 속성에 Process 액세스해서는 안 됩니다. 그렇지 않으면 .NET Core에서 속성은 StartInfo 를 throw InvalidOperationException 하고 .NET Framework 더미 ProcessStartInfo 개체를 반환합니다.

프로세스가 시작되면 파일 이름은 (읽기 전용) MainModule 속성을 채우는 파일입니다. 프로세스가 시작된 후 프로세스와 연결된 실행 파일을 검색하려면 속성을 사용합니다 MainModule . 연결된 프로세스가 시작되지 않은 instance 실행 파일을 Process 설정하려면 속성의 FileName 멤버를 StartInfo 사용합니다. 속성의 StartInfo 멤버는 프로세스의 메서드에 Start 전달되는 인수이므로 연결된 프로세스가 시작된 후 속성을 변경 FileName 해도 속성이 다시 설정 MainModule 되지 않습니다. 이러한 속성은 연결된 프로세스를 초기화하는 데만 사용됩니다.

적용 대상

추가 정보