英語で読む

次の方法で共有


ProcessStartInfo.UseShellExecute プロパティ

定義

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

public bool UseShellExecute { get; set; }

プロパティ値

プロセスを起動するときにシェルを使用する場合は true。プロセスを実行可能ファイルから直接作成する場合は false。 既定値は、true.NET Framework アプリと false .NET Core アプリです。

例外

ユニバーサル Windows プラットフォーム (UWP) アプリで値を true に設定することが試みられます。

// Run "csc.exe /r:System.dll /out:sample.exe stdstr.cs". UseShellExecute is false because we're specifying
// an executable directly and in this case depending on it being in a PATH folder. By setting
// RedirectStandardOutput to true, the output of csc.exe is directed to the Process.StandardOutput stream
// which is then displayed in this console window directly.
using (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();
}

注釈

この API の詳細については、「 ProcessStartInfo.UseShellExecute の補足 API 解説」を参照してください。

適用対象

こちらもご覧ください