2

I am firing up a cmd console from my .net app with some parameters, is there a parameter to specify that the cmd console is not visible?

---- Edit - Adding Code

I know this isn't the standard way of starting a process in .Net, but it is being run from a Silverlight Client.

  Dynamic cmd = AutomationFactory.CreateObject("WScript.Shell");
    cmd.Run("C:\Windows\System32\cmd.exe /c *myargs*")
Ben
  • 3,926
  • 12
  • 54
  • 87

3 Answers3

1

After some more digging, I have found out that this will work -

   Dynamic cmd = AutomationFactory.CreateObject("WScript.Shell");
    cmd.Run("C:\Windows\System32\cmd.exe /c *myargs*",0,true);
Ben
  • 3,926
  • 12
  • 54
  • 87
0

If you never want the application to show a console window, one way is, after creating the console application, to change the application Output Type to "Windows Application" (project properties / Application tab / Output type).

Mark Wilkins
  • 40,729
  • 5
  • 57
  • 110
0

You could have a look at this solution:

Show/Hide the console window of a C# console application

or alternatively, make your project a GUI project but without any forms and use the classes in the System.Diagnostics namespace to execute your commands. Probably requires much refactoring though.

Community
  • 1
  • 1
Nobody
  • 4,731
  • 7
  • 36
  • 65