Hi.
Is System.Diagnostics.Process.Start the appropriate .Net alternative for shelling a process?
Does a .Net call have better performance than CreateProcessA or OS-COMMAND?
TIA!
OS-COMMAND SILENT (or OS-COMMAND with no option) launches a shell to execute the command (so, as Simon pointed out, two processes are created) but the shell's console window is hidden. OS-COMMAND NO-CONSOLE launches the process directly without a shell so only one process is created. Both use CreateProcess to do their work. There is a bit of extra overhead using OS-COMMAND NO-CONSOLE as compared to calling CreateProcess directly as an external procedure because OS-COMMAND always checks for the existence of a helper executable even if it's not going to be used. I've made a note to myself to fix that.
I believe that INPUT-OUTPUT THROUGH launches a command shell because it's the most reliable way to redirect stdin and stdout on all versions of Windows.
Yes, the Process class is the recommended way to start processes in .NET. Calling CreateProcessA directly is probably slightly faster but the time it takes to actually launch a process will surely swamp whatever slight gains you get from avoiding a .NET call.
Yes, the Process class is the recommended way to start processes in .NET. Calling CreateProcessA directly is probably slightly faster but the time it takes to actually launch a process will surely swamp whatever slight gains you get from avoiding a .NET call.
Flag this post as spam/abuse.
If you run OS-COMMAND without the SILENT option, as DOS box will open / flash, so I suspect that OS-COMMNAND will launch a shell and then execute the command in the shell, thus it creates a process (cmd.exe), establish an environment, and then launch your process from within that shell.
For that reason I believe that not using OS-COMMAND comes down to directly creating the single process you want as opposed to creating a shell to create the process you need.
But this is a wild guess. Maybe someone can tell us what OS-COMMAND actually does (and why INPUT-THROUGH will always flash a dos box).
OS-COMMAND SILENT (or OS-COMMAND with no option) launches a shell to execute the command (so, as Simon pointed out, two processes are created) but the shell's console window is hidden. OS-COMMAND NO-CONSOLE launches the process directly without a shell so only one process is created. Both use CreateProcess to do their work. There is a bit of extra overhead using OS-COMMAND NO-CONSOLE as compared to calling CreateProcess directly as an external procedure because OS-COMMAND always checks for the existence of a helper executable even if it's not going to be used. I've made a note to myself to fix that.
I believe that INPUT-OUTPUT THROUGH launches a command shell because it's the most reliable way to redirect stdin and stdout on all versions of Windows.
Thanks Matt
OS-COMMAND SILENT (or OS-COMMAND with no option) launches a shell to execute the command (so, as Simon pointed out, two processes are created) but the shell's console window is hidden. OS-COMMAND NO-CONSOLE launches the process directly without a shell so only one process is created. Both use CreateProcess to do their work. There is a bit of extra overhead using OS-COMMAND NO-CONSOLE as compared to calling CreateProcess directly as an external procedure because OS-COMMAND always checks for the existence of a helper executable even if it's not going to be used. I've made a note to myself to fix that.
I believe that INPUT-OUTPUT THROUGH launches a command shell because it's the most reliable way to redirect stdin and stdout on all versions of Windows.
Flag this post as spam/abuse.
I think this question IS answered, by the SAME GUY who made the THING himself.. ? (...and thanks for that)