ProcessStartInfoとは? わかりやすく解説

Process.StartInfo プロパティ

Process の Start メソッドに渡すプロパティを取得または設定します。

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

Public Property StartInfo As
 ProcessStartInfo
Dim instance As Process
Dim value As ProcessStartInfo

value = instance.StartInfo

instance.StartInfo = value
public ProcessStartInfo StartInfo { get; set;
 }
public:
property ProcessStartInfo^ StartInfo {
    ProcessStartInfo^ get ();
    void set (ProcessStartInfo^ value);
}
/** @property */
public ProcessStartInfo get_StartInfo ()

/** @property */
public void set_StartInfo (ProcessStartInfo
 value)
public function get StartInfo
 () : ProcessStartInfo

public function set StartInfo
 (value : ProcessStartInfo)

プロパティ値
プロセスを起動するときに使用するデータを表す ProcessStartInfo。これらの引数には、プロセスの起動時に使用する実行可能ファイルまたは文書の名前があります。

例外例外
例外の種類条件

ArgumentNullException

StartInfo を指定する値が null 参照 (Visual Basic では Nothing) です。

解説解説

StartInfo は、プロセスを起動するために使用するパラメータのセットを表します。Start を呼び出すときは、StartInfo を使用して、起動するプロセスを指定します。設定する必要がある唯一の StartInfo メンバは、FileName プロパティです。FileName プロパティの指定によるプロセスの起動は、Windows の [スタート] メニューの [ファイル名を指定して実行] ダイアログ ボックスへの情報の入力と同様です。そのため、FileName プロパティで実行可能ファイルを表す必要はありません。システムにインストールされているアプリケーションに関連付けられている拡張子を持つ任意のファイルの種類を指定できます。たとえば、テキスト ファイルをメモ帳などのエディタに関連付けている場合は、FileName に拡張子 .txt の付いたファイルを使用できます。.doc ファイルを Microsoft Word などのワード プロセッシング ツールに関連付けている場合は、.doc を使用できます。同様に、[ファイル名を指定して実行] ダイアログ ボックスで実行可能ファイル名は拡張子 .exe が付いているかどうかに関係なく受け入れられるのと同じように、FileName メンバでも拡張子 .exe は省略できます。たとえば、FileName プロパティには "Notepad.exe" または "Notepad" を設定できます。

ファイル名が .doc ファイルなど実行可能ファイル以外のファイルの場合は、ファイルに対して実行するアクションを指定する動詞を含めることができます。たとえば、拡張子 .doc で終わるファイルの場合、Verb に "Print" を設定できます。Verb プロパティの値を手動で入力する場合、FileName プロパティで指定するファイル名に拡張子を付ける必要はありません。ただし、使用できる動詞を判断するのに Verbs プロパティを使用する場合は、ファイル拡張子を付ける必要があります。

Start メソッドがプロセスで呼び出される前であれば、StartInfo プロパティで指定したパラメータを変更できます。プロセス開始後は、StartInfo 値を変更しても、関連付けられたプロセスの開始やプロセスへの反映は行われません。ProcessStartInfo.UserName プロパティと ProcessStartInfo.Password プロパティを設定してStart(ProcessStartInfo) を呼び出した場合、アンマネージ関数 CreateProcessWithLogonW が呼び出されます。これにより、CreateNoWindow プロパティの値が true の場合や、WindowStyle プロパティの値が Hidden の場合でも、新しいウィンドウでプロセスが開始されます。

プロセスの開始に Start メソッドを使用しなかった場合、StartInfo プロパティはプロセス開始に使用されたパラメータを反映しません。たとえば、GetProcesses を使用してコンピュータで実行中のプロセスの配列を取得する場合、各 Process の StartInfo プロパティには、プロセス開始に使用された元のファイル名や引数は含まれません。

プロセスを起動するとき、このファイル名が (読み取り専用) MainModule プロパティに設定されるファイルになります。プロセスを起動した後でプロセスに関連付けられた実行可能ファイルを取得するには、MainModule プロパティを使用します。関連付けられたプロセスがまだ起動されていない Process インスタンスの実行可能ファイルを設定するには、StartInfo プロパティの FileName メンバを使用します。StartInfo プロパティのメンバは、プロセスの Start メソッドに渡される引数であるため、関連付けられたプロセスが起動された後で FileName プロパティを変更しても、MainModule プロパティはリセットされません。これらのプロパティは、関連付けられたプロセスの初期化にだけ使用します。

使用例使用例

実行するファイル、それに対して実行するアクション、およびユーザー インターフェイスを表示するかどうかを指定する値を StartInfo に格納する例を次に示します。

Imports System
Imports System.Diagnostics
Imports System.ComponentModel


Namespace MyProcessSample
    _
   '/ <summary>
   '/ Shell for the sample.
   '/ </summary>
   Class MyProcess
      ' These are the Win32 error code for file not found or access
 denied.
      Private ERROR_FILE_NOT_FOUND As Integer
 = 2
      Private ERROR_ACCESS_DENIED As Integer
 = 5
      
      
      '/ <summary>
      '/ Prints a file with a .doc extension.
      '/ </summary>
      Sub PrintDoc()
         Dim myProcess As New
 Process()
         
         Try
            ' Get the path that stores user documents.
            Dim myDocumentsPath As String
 = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
            
            myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
            myProcess.StartInfo.Verb = "Print"
            myProcess.StartInfo.CreateNoWindow = True
            myProcess.Start()
         Catch e As Win32Exception
            If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
               Console.WriteLine((e.Message + ". Check the path."))
            
            Else
               If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
                  ' Note that if your word processor might generate
 exceptions
                  ' such as this, which are handled first.
                  Console.WriteLine((e.Message + ". You do not
 have permission to print this file."))
               End If
            End If
         End Try
      End Sub 'PrintDoc
      
      
      Public Shared Sub
 Main()
         Dim myProcess As New
 MyProcess()
         myProcess.PrintDoc()
      End Sub 'Main
   End Class 'MyProcess
End Namespace 'MyProcessSample
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    /// <summary>
    /// Shell for the sample.
    /// </summary>
    class MyProcess
    {
        // These are the Win32 error code for file not found or access
 denied.
        const int ERROR_FILE_NOT_FOUND =2;
        const int ERROR_ACCESS_DENIED = 5;

        /// <summary>
        /// Prints a file with a .doc extension.
        /// </summary>
        void PrintDoc()
        {
            Process myProcess = new Process();
            
            try
            {
                // Get the path that stores user documents.
                string myDocumentsPath = 
                    Environment.GetFolderPath(Environment.SpecialFolder.Personal);

                myProcess.StartInfo.FileName = myDocumentsPath + "\\MyFile.doc";
 
                myProcess.StartInfo.Verb = "Print";
                myProcess.StartInfo.CreateNoWindow = true;
                myProcess.Start();
            }
            catch (Win32Exception e)
            {
                if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND)
                {
                    Console.WriteLine(e.Message + ". Check the path.");
                } 

                else if (e.NativeErrorCode
 == ERROR_ACCESS_DENIED)
                {
                    // Note that if your word processor might generate
 exceptions
                    // such as this, which are handled first.
                    Console.WriteLine(e.Message + 
                        ". You do not have permission to print this
 file.");
                }
            }
        }


        public static void
 Main()
        {
            MyProcess myProcess = new MyProcess();
            myProcess.PrintDoc();
        }
    }
}
#using <System.dll>

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

// These are the Win32 error code for file not found or access denied.
#define ERROR_FILE_NOT_FOUND 2
#define ERROR_ACCESS_DENIED  5
int main()
{
   Process^ myProcess = gcnew Process;
   try
   {
      
      // Get the path that stores user documents.
      String^ myDocumentsPath = Environment::GetFolderPath( Environment::SpecialFolder::Personal
 );
      myProcess->StartInfo->FileName = String::Concat( myDocumentsPath, "\\MyFile.doc"
 );
      myProcess->StartInfo->Verb = "Print";
      myProcess->StartInfo->CreateNoWindow = true;
      myProcess->Start();
   }
   catch ( Win32Exception^ e ) 
   {
      if ( e->NativeErrorCode == ERROR_FILE_NOT_FOUND )
      {
         Console::WriteLine( "{0}. Check the path.", e->Message );
      }
      else
      if ( e->NativeErrorCode == ERROR_ACCESS_DENIED )
      {
         
         // Note that if your word processor might generate exceptions
         // such as this, which are handled first.
         Console::WriteLine( "{0}. You do not have permission to print this
 file.", e->Message );
      }
   }

}

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProcessStartInfo クラス

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

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

Public NotInheritable Class
 ProcessStartInfo
Dim instance As ProcessStartInfo
public sealed class ProcessStartInfo
public ref class ProcessStartInfo sealed
public final class ProcessStartInfo
public final class ProcessStartInfo
解説解説
メモメモ

このクラスに適用される HostProtectionAttribute 属性の Resources プロパティの値は、SharedState または SelfAffectingProcessMgmt です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的には、アイコンをダブルクリック、コマンドを入力、またはブラウザに URL を入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラスのトピックまたは「SQL Server プログラミングとホスト保護属性」を参照してください。

ProcessStartInfo は、Process コンポーネントと組み合わせて使用します。Process クラスを使用してプロセスを起動すると、実行中のプロセスに接続するときに利用できる情報だけでなく、プロセス情報にもアクセスできます。

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

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

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

UseShellExecute を設定し、オペレーティング システムのシェルを使用してプロセスを起動するかどうかを指定します。

ProcessStartInfo プロパティの値を変更できるのは、プロセスを起動するまでです。プロセスを開始した後で、これらの値を変更しても影響はありません。

使用例使用例
Imports System
Imports System.Diagnostics
Imports System.ComponentModel


Namespace MyProcessSample
    _
   '/ <summary>
   '/ Shell for the sample.
   '/ </summary>
   Class MyProcess 
      '/ <summary>
      '/ Opens the Internet Explorer application.
      '/ </summary>
      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 'OpenApplication
       
      
      '/ <summary>
      '/ Opens urls and .html documents using Internet Explorer.
      '/ </summary>
      Sub 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")
      End Sub 'OpenWithArguments
      
      
      '/ <summary>
      '/ Uses the ProcessStartInfo class to start new processes, both
 in a minimized 
      '/ mode.
      '/ </summary>
      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 'OpenWithStartInfo
       
      
      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 'Main 
   End Class 'MyProcess
End Namespace 'MyProcessSample
using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    /// <summary>
    /// Shell for the sample.
    /// </summary>
    class MyProcess
    {
       
        /// <summary>
        /// Opens the Internet Explorer application.
        /// </summary>
        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);
 
        }
        
        /// <summary>
        /// Opens urls and .html documents using Internet Explorer.
        /// </summary>
        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");
        }
        
        /// <summary>
        /// Uses the ProcessStartInfo class to start new processes,
 both in a minimized 
        /// mode.
        /// </summary>
        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();

               }    
    }
}
#using <System.dll>

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

/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
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 );
}


/// <summary>
/// Opens urls and .html documents using Internet Explorer.
/// </summary>
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" );
}


/// <summary>
/// Uses the ProcessStartInfo class to start new processes, both in
 a minimized 
/// mode.
/// </summary>
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();
}

.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Diagnostics.ProcessStartInfo
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProcessStartInfo コンストラクタ ()

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

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

Dim instance As New ProcessStartInfo
public ProcessStartInfo ()
public:
ProcessStartInfo ()
public ProcessStartInfo ()
public function ProcessStartInfo ()
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProcessStartInfo コンストラクタ (String)

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

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProcessStartInfo コンストラクタ (String, String)

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

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProcessStartInfo コンストラクタ


ProcessStartInfo プロパティ


ProcessStartInfo メソッド


ProcessStartInfo メンバ

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

ProcessStartInfo データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「ProcessStartInfo」の関連用語

ProcessStartInfoのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProcessStartInfoのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS