Boulderdude

Is it possible to not show the command shell while executing a command line executable using the system() call

Re: Common Language Runtime Not showing command prompt window on a system() call

Boulderdude

I got a clue to use CreateProcess instead of system(). I'm using VS2005, can anybody tell me what the .NET equivalent of CreateProcess is

I tried System::Diagnostics::Process but still showed the command window.

Process ^myProc = gcnew Process;

myProc->Start("diskpart /s sample.txt");





Re: Common Language Runtime Not showing command prompt window on a system() call

Lucian Bargaoanu

ProcessStartInfo startInfo = new ProcessStartInfo(@"c:\Projects\Win32Console2003\Debug\Win32Console2003.exe");

startInfo.WindowStyle = ProcessWindowStyle.Hidden;

Process.Start(startInfo);





Re: Common Language Runtime Not showing command prompt window on a system() call

Boulderdude

Why doesnt this work -

ProcessStartInfo ^myproc = gcnew ProcessStartInfo();

myproc->FileName = "diskpart.exe";

myproc->Arguments = "/s disk.txt > diskout.txt";

myproc->WindowStyle = ProcessWindowStyle::Hidden;

myproc->UseShellExecute = true;

Process::Start(myproc);

The output file diskout.txt doesnt get created. Something is not right....





Re: Common Language Runtime Not showing command prompt window on a system() call

4Funnah

Another answer is just to call 'ShellExecute' with the SW_HIDE parameter. This worked beautifully for me, especially when you don't have access to the code for the .exe file you're trying to call...

ShellExecute(0, "open", "whatever.exe", args, 0, SW_HIDE);