ProcessStartInfo クラス

定義

プロセスを起動するときに使用する値のセットを指定します。

public ref class ProcessStartInfo sealed
public sealed class ProcessStartInfo
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public sealed class ProcessStartInfo
type ProcessStartInfo = class
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type ProcessStartInfo = class
Public NotInheritable Class ProcessStartInfo
継承
ProcessStartInfo
属性

次のコード例では、 クラスを使用ProcessStartInfoしてインターネット エクスプローラーを開始する方法を示します。 宛先 URL は引数として ProcessStartInfo 提供されます。

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
using namespace System::ComponentModel;

// Opens the Internet Explorer application.
void OpenApplication(String^ myFavoritesPath)
{
    // Start Internet Explorer. Defaults to the home page.
    Process::Start("IExplore.exe");

    // Display the contents of the favorites folder in the browser.
    Process::Start(myFavoritesPath);
}

// Opens urls and .html documents using Internet Explorer.
void OpenWithArguments()
{
    // URLs are not considered documents. They can only be opened
    // by passing them as arguments.
    Process::Start("IExplore.exe", "www.northwindtraders.com");

    // Start a Web page using a browser associated with .html and .asp files.
    Process::Start("IExplore.exe", "C:\\myPath\\myFile.htm");
    Process::Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}

// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
    ProcessStartInfo^ startInfo = gcnew ProcessStartInfo("IExplore.exe");
    startInfo->WindowStyle = ProcessWindowStyle::Minimized;
    Process::Start(startInfo);
    startInfo->Arguments = "www.northwindtraders.com";
    Process::Start(startInfo);
}

int main()
{
    // Get the path that stores favorite links.
    String^ myFavoritesPath = Environment::GetFolderPath(Environment::SpecialFolder::Favorites);
    OpenApplication(myFavoritesPath);
    OpenWithArguments();
    OpenWithStartInfo();
}
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        // Opens the Internet Explorer application.
        void OpenApplication(string myFavoritesPath)
        {
            // Start Internet Explorer. Defaults to the home page.
            Process.Start("IExplore.exe");

            // Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath);
        }

        // Opens urls and .html documents using Internet Explorer.
        void OpenWithArguments()
        {
            // url's are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com");

            // Start a Web page using a browser associated with .html and .asp files.
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
        }

        // Uses the ProcessStartInfo class to start new processes,
        // both in a minimized mode.
        void OpenWithStartInfo()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;

            Process.Start(startInfo);

            startInfo.Arguments = "www.northwindtraders.com";

            Process.Start(startInfo);
        }

        static void Main()
        {
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            MyProcess myProcess = new MyProcess();

            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();
        }
    }
}
Imports System.Diagnostics
Imports System.ComponentModel

Namespace MyProcessSample
    Class MyProcess
        ' Opens the Internet Explorer application.
        Public Sub OpenApplication(myFavoritesPath As String)
            ' Start Internet Explorer. Defaults to the home page.
            Process.Start("IExplore.exe")

            ' Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath)
        End Sub

        ' Opens URLs and .html documents using Internet Explorer.
        Sub OpenWithArguments()
            ' URLs are not considered documents. They can only be opened
            ' by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com")

            ' Start a Web page using a browser associated with .html and .asp files.
            Process.Start("IExplore.exe", "C:\myPath\myFile.htm")
            Process.Start("IExplore.exe", "C:\myPath\myFile.asp")
        End Sub

        ' Uses the ProcessStartInfo class to start new processes,
        ' both in a minimized mode.
        Sub OpenWithStartInfo()
            Dim startInfo As New ProcessStartInfo("IExplore.exe")
            startInfo.WindowStyle = ProcessWindowStyle.Minimized

            Process.Start(startInfo)

            startInfo.Arguments = "www.northwindtraders.com"

            Process.Start(startInfo)
        End Sub

        Shared Sub Main()
            ' Get the path that stores favorite links.
            Dim myFavoritesPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Favorites)

            Dim myProcess As New MyProcess()

            myProcess.OpenApplication(myFavoritesPath)
            myProcess.OpenWithArguments()
            myProcess.OpenWithStartInfo()
        End Sub
    End Class
End Namespace 'MyProcessSample

注釈

ProcessStartInfo は、 コンポーネントと共に使用されます Process 。 クラスを使用して Process プロセスを開始すると、実行中のプロセスにアタッチするときに使用できる情報に加えて、プロセス情報にアクセスできます。

クラスを ProcessStartInfo 使用して、開始するプロセスをより適切に制御できます。 少なくとも、 プロパティを FileName 手動で設定するか、コンストラクターを使用して設定する必要があります。 ファイル名は任意のアプリケーションまたはドキュメントです。 ここで、ドキュメントは、開いているアクションまたは既定のアクションが関連付けられている任意のファイルの種類として定義されています。 オペレーティング システムで使用できる [ フォルダー オプション] ダイアログ ボックスを使用して、登録済みのファイルの種類とコンピューターに関連付けられているアプリケーションを表示できます。 [ 詳細設定 ] ボタンをクリックすると、特定の登録済みファイルの種類に関連付けられている開いているアクションがあるかどうかを示すダイアログ ボックスが表示されます。

さらに、そのファイルで実行するアクションを定義する他のプロパティを設定することもできます。 プロパティのプロパティの型に固有の値をFileNameVerb指定できます。 たとえば、文書の種類に "印刷" を指定できます。 また、プロパティ値をコマンド ライン引数として指定 Arguments して、ファイルの開いているプロシージャに渡すこともできます。 たとえば、 プロパティでテキスト エディター アプリケーションを FileName 指定する場合は、 プロパティを Arguments 使用して、エディターで開くテキスト ファイルを指定できます。

標準入力は通常キーボードで、標準出力と標準エラーは通常モニター画面です。 ただし、および RedirectStandardError の各プロパティをRedirectStandardOutputRedirectStandardInput使用すると、プロセスがファイルやその他のデバイスから入力を取得したり、出力を返したりすることができます。 コンポーネントで 、、または StandardError プロパティをStandardInput使用するProcess場合は、まず、 プロパティに対応する値を設定するProcessStartInfo必要があります。 StandardOutput それ以外の場合、ストリームの読み取りまたは書き込み時にシステムによって例外がスローされます。

プロパティを UseShellExecute 設定して、オペレーティング システム シェルを使用してプロセスを開始するかどうかを指定します。 が に設定されている場合UseShellExecute、新しいプロセスは、呼び出し元プロセスの標準入力、標準出力、標準エラー ストリームをそれぞれ に設定trueしない限りRedirectStandardInputRedirectStandardOutputRedirectStandardError、 を継承します。false

プロセスが開始するまで、任意 ProcessStartInfo のプロパティの値を変更できます。 プロセスを開始した後、これらの値を変更しても効果はありません。

重要

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

注意

このクラスには、すべてのメンバーに適用されるクラス レベルでのリンク要求が含まれています。 SecurityException直接呼び出し元に完全信頼アクセス許可がない場合は、 がスローされます。 セキュリティ要求の詳細については、「リンク確認要求」を参照してください。

コンストラクター

ProcessStartInfo()

プロセスを起動するときに使用するファイル名を指定せずに、ProcessStartInfo クラスの新しいインスタンスを初期化します。

ProcessStartInfo(String)

ProcessStartInfo クラスの新しいインスタンスを初期化し、アプリケーションやドキュメントなど、プロセスを起動するときに使用するファイル名を指定します。

ProcessStartInfo(String, IEnumerable<String>)

プロセスを起動するときに使用する値のセットを指定します。

ProcessStartInfo(String, String)

プロセスを起動するときに使用するアプリケーション ファイル名およびアプリケーションに渡すコマンド ライン引数のセットを指定して、ProcessStartInfo クラスの新しいインスタンスを初期化します。

プロパティ

ArgumentList

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

Arguments

アプリケーションを起動するときに使用するコマンド ライン引数のセットを取得または設定します。

CreateNoWindow

プロセスを新しいウィンドウで起動するかどうかを示す値を取得または設定します。

Domain

プロセスを開始するときに使用されるドメインを指定する値を取得または設定します。 この値が null の場合は、UserName プロパティを UPN 形式で指定する必要があります。

Environment

このプロセスとその子プロセスに適用される環境変数を取得します。

EnvironmentVariables

ファイルの検索パス、一時ファイルのディレクトリ、アプリケーション固有のオプションなどの情報を取得します。

ErrorDialog

プロセスを起動できなかったときにエラー ダイアログ ボックスを表示するかどうかを示す値を取得または設定します。

ErrorDialogParentHandle

プロセスを起動できないときにエラー ダイアログ ボックスを表示するのに使用するウィンドウ ハンドルを取得または設定します。

FileName

起動するアプリケーションまたはドキュメントを取得または設定します。

LoadUserProfile

Windows ユーザー プロファイルをレジストリから読み込むかどうかを示す値を取得または設定します。

Password

プロセスを開始するときに使用するユーザー パスワードを格納するセキュリティ文字列を取得または設定します。

PasswordInClearText

プロセスの開始時に使用する、クリア テキストのユーザーのパスワードを取得または設定します。

RedirectStandardError

アプリケーションのエラー出力を StandardError ストリームに書き込むかどうかを示す値を取得または設定します。

RedirectStandardInput

アプリケーションの入力を StandardInput ストリームから読み取るかどうかを示す値を取得または設定します。

RedirectStandardOutput

アプリケーションのテキスト出力を StandardOutput ストリームに書き込むかどうかを示す値を取得または設定します。

StandardErrorEncoding

エラー出力に最適なエンコーディングを取得または設定します。

StandardInputEncoding

標準入力に最適なエンコードを取得または設定します。

StandardOutputEncoding

標準出力に最適なエンコーディングを取得または設定します。

UseCredentialsForNetworkingOnly

プロセスを起動するときに使用する値のセットを指定します。

UserName

プロセスを開始するときに使用するユーザー名を取得または設定します。 UPN 形式 (user@DNS_domain_name) を使用する場合は、Domain プロパティを null に設定する必要があります。

UseShellExecute

プロセスの起動にオペレーティング システムのシェルを使用するかどうかを示す値を取得または設定します。

Verb

FileName プロパティで指定したアプリケーションまたはドキュメントを開くときに使用する動詞を取得または設定します。

Verbs

FileName プロパティで指定したファイルの種類に関連付けられている動詞のセットを取得します。

WindowStyle

プロセスを起動するときに使用するウィンドウの状態を取得または設定します。

WorkingDirectory

UseShellExecute プロパティが false の場合に、開始するプロセスの作業ディレクトリを取得または設定します。 UseShellExecutetrue の場合に、開始するプロセスを含むディレクトリを取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください