469,934 Members | 1,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

suppressing the console window

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?

Jun 22 '06 #1
4 2978
pd***********@hotmail.com wrote:
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

Jun 22 '06 #2
pd***********@hotmail.com wrote:
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

--
Simon.
Jun 22 '06 #3
In article <4f*************@uni-berlin.de>,
Ulrich Eckhardt <do******@knuut.de> wrote:
pd***********@hotmail.com wrote:
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:


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).

--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
Jun 22 '06 #4
pd***********@hotmail.com wrote:
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.
Jun 22 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by John Salerno | last post: by
2 posts views Thread by stevie.greenslade | last post: by
10 posts views Thread by Stephany Young | last post: by
1 post views Thread by janefield2002 | last post: by
5 posts views Thread by Don Li | last post: by
5 posts views Thread by =?Utf-8?B?SmFtZXMgV29uZw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.