Reputation: 720
So I'm currently trying to start the Command Prompt window from my ASP.NET Core MVC WebApp which is running in Debug mode when I click a button but for some reason it won't start unless I specify UseShellExecute
and set it to True.
This is a problem since if I do set it to True I can't redirect standard input which is a bad thing. I need to be able to do that.
Here is the code
public static void Start(string dirPath)
{
Process serverProcess = new Process
{
StartInfo =
{
CreateNoWindow = false,
FileName = "cmd.exe",
Arguments = "",
WindowStyle = ProcessWindowStyle.Maximized,
RedirectStandardInput = true
}
};
serverProcess.Start()
}
It does invoke the code, because keep in mind, it works when I do UseShellExecute = True
and it also hits the breakpoints etc.
How do I start the cmd or a specific batch file without setting UseShellExecute = True ?
Upvotes: 0
Views: 190
Reputation: 27538
UseShellExecute
is false by default for Core . If you don't want to set UseShellExecute
. Try setting Arguments
below as workaround :
Arguments = $"/c start cmd.exe",
Reference : https://github.com/dotnet/corefx/issues/21767
Upvotes: 1