suppressing the console window

P

pdmountaineer

hi,

with the well-known C command "system", DOS commands can be executed
from a simple C-program. Is there a possibility to suppress the console
window to pop up when executing a DOS command from C?
 
U

Ulrich Eckhardt

with the well-known C command "system", DOS commands can be executed
from a simple C-program.

Wait a second here. Using system() (which is a function and not
a 'command'), you can execute arbitrary programs (not just 'DOS commands',
whatever you mean with that). However, these programs are always executed
in an intermediate shell, not directly, which on MS Windows causes this:
Is there a possibility to suppress the console
window to pop up when executing a DOS command from C?

So, the answer is yes and no. No, because you can't keep that shell from
being executed but yes, there are other means to directly execute a
process. Under win32, the function is called CreateProcess(), but as this
is not general C anymore please redirect further discussion or queries to
a win32-related newsgroup.

HTH

Uli
 
S

Simon Biber

hi,

with the well-known C command "system", DOS commands can be executed
from a simple C-program.

Yes, that may well be the way that "system" works on your system. It
typically passes the string to a command interpreter. That will be
COMMAND.COM on MS-DOS and Windows versions up to 95/98/Me, and cmd.exe
on Windows NT, 2000, XP, 2003 and Vista. On Unix systems it's often the
shell /bin/sh.
Is there a possibility to suppress the console
window to pop up when executing a DOS command from C?

That's an issue that isn't specified in the C language. Certainly, there
will be a way, but it will involve using system-specific functions. The
use of such functions is not discussed on this group. You need a group
that talks about Windows programming. Perhaps
comp.os.ms-windows.programmer.win32
 
W

Walter Roberson

Wait a second here. Using system() (which is a function and not
a 'command'), you can execute arbitrary programs (not just 'DOS commands',
whatever you mean with that). However, these programs are always executed
in an intermediate shell, not directly, which on MS Windows causes this:

C89:

The system function passes the string pointed to by string to
the host environment to be executed by a command processor in an
implementation-defined manner.

There's nothing in there about being able to execute "arbitrary
programs"; nor is there anything in there about an "intermediate shell".
You get a "command processor" [at most -- there doesn't even have
to be that], and it does whatever it wants with the string.

This isn't just a theoretical limitation: the "command processor"
could be, for example, "rsh", the Restricted Bourne Shell, which
does NOT permit "arbitrary programs" to be executed (only built-in
commands and programs that can be found in the rsh PATH).
 
J

jacob navia

hi,

with the well-known C command "system", DOS commands can be executed
from a simple C-program. Is there a possibility to suppress the console
window to pop up when executing a DOS command from C?

If you use lcc-win32, there is the function

int System(const char *cmd, int nCmdShow);

nCmdShow will allow you to hide the window (making the
spawned process completely invisible), or the other
values of SW_* like SW_HIDDEN SW_SHOW _SW_NORMAL SW_MINIMIZE, etc.

Standard C doesn't have any notion of GUI environments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top