ProcessStartInfo.UseShellExecute プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ProcessStartInfo.UseShellExecute プロパティの意味・解説 

ProcessStartInfo.UseShellExecute プロパティ

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

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

Dim instance As ProcessStartInfo
Dim value As Boolean

value = instance.UseShellExecute

instance.UseShellExecute = value
public bool UseShellExecute { get;
 set; }
public:
property bool UseShellExecute {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_UseShellExecute ()

/** @property */
public void set_UseShellExecute (boolean value)
public function get UseShellExecute
 () : boolean

public function set UseShellExecute
 (value : boolean)

プロパティ値
プロセスを起動するときにシェルを使用する場合は true。それ以外の場合、プロセスは実行可能ファイルから直接作成されます。既定値は true です。

解説解説

このプロパティを false に設定すると、入力、出力、エラーの各ストリームをリダイレクトできます。

メモメモ

   UserName プロパティが null 参照 (Visual Basic では Nothing) や空の文字列でない場合、または Process.Start(ProcessStartInfo) メソッドを呼び出したときに InvalidOperationException がスローされる場合、UseShellExecute を false に設定する必要があります。

オペレーティング システムのシェルを使用してプロセスを起動すると、Process コンポーネントを使用して、任意のドキュメント (任意の登録済みファイル タイプ。既定の "open" アクションが実行できるように関連付けられています。) を起動し、印刷などのファイルに対する操作を実行できます。UseShellExecute が false の場合は、Process コンポーネントを使用して、実行可能ファイルの起動だけ実行できます。

メモメモ

ErrorDialog プロパティを true に設定するには、UseShellExecute を true にする必要があります。

WorkingDirectory プロパティの動作は、UseShellExecute が true の場合と UseShellExecute が false の場合とで異なります。UseShellExecute が true の場合は、WorkingDirectory プロパティは実行可能ファイルの場所を指定します。WorkingDirectory が空の文字列の場合は、現在のディレクトリに実行可能ファイルが格納されていると解釈されます。

UseShellExecute が false の場合は、実行可能ファイルの検索に WorkingDirectory プロパティは使用されません。代わりに、このプロパティは起動されるプロセスにより使用され、新しいプロセスのコンテキスト内でだけ意味を持ちます。

使用例使用例
compiler.StartInfo.FileName = "csc.exe"
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe
 stdstr.cs"
compiler.StartInfo.UseShellExecute = False
compiler.StartInfo.RedirectStandardOutput = True
compiler.Start()

Console.WriteLine(compiler.StandardOutput.ReadToEnd())

compiler.WaitForExit()
Process compiler = new Process();
compiler.StartInfo.FileName = "csc.exe";
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();    

Console.WriteLine(compiler.StandardOutput.ReadToEnd());

compiler.WaitForExit();
Process^ compiler = gcnew Process;
compiler->StartInfo->FileName = "cl.exe";
compiler->StartInfo->Arguments = "/clr stdstr.cpp /link /out:sample.exe";
compiler->StartInfo->UseShellExecute = false;
compiler->StartInfo->RedirectStandardOutput = true;
compiler->Start();

Console::WriteLine( compiler->StandardOutput->ReadToEnd() );

compiler->WaitForExit();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProcessStartInfo クラス
ProcessStartInfo メンバ
System.Diagnostics 名前空間
ProcessStartInfo.RedirectStandardInput プロパティ
ProcessStartInfo.RedirectStandardOutput プロパティ
ProcessStartInfo.RedirectStandardError プロパティ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ProcessStartInfo.UseShellExecute プロパティ」の関連用語

ProcessStartInfo.UseShellExecute プロパティのお隣キーワード
検索ランキング

   

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



ProcessStartInfo.UseShellExecute プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS