Process.StartInfoとは? わかりやすく解説

Process.StartInfo プロパティ

ProcessStart メソッドに渡すプロパティ取得または設定します

名前空間: 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 を使用してコンピュータ実行中のプロセス配列取得する場合、各 ProcessStartInfo プロパティには、プロセス開始使用された元のファイル名引数含まれません。

プロセス起動するとき、このファイル名が (読み取り専用) 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 コンポーネントStandardInputStandardOutput、または 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 データ型公開されるメンバを以下の表に示します


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


このページでは「.NET Framework クラス ライブラリ リファレンス」からProcess.StartInfoを検索した結果を表示しています。
Weblioに収録されているすべての辞書からProcess.StartInfoを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からProcess.StartInfo を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Process.StartInfo」の関連用語

1
6% |||||

Process.StartInfoのお隣キーワード
検索ランキング

   

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



Process.StartInfoのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS