473,382 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 3230
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
1
by: Bill Woodruff | last post by:
I know, it's a weird question, but I am experimenting with a multi-form app where I need to override Dispose calls and want to start the app this way. thanks, Bill Woodruff dotScience Chiang...
2
by: John Salerno | last post by:
Hi guys. I tried naming my file with a .pyw extension, but the console still shows up. Why doesn't this work? And is there another, more programmatic way to suppress it? Thanks.
2
by: stevie.greenslade | last post by:
'Lo all. I have a simple question I'd like help on. :] How, if at all, would one go about suppressing the console window that flashes up when you make at system() call in your C++ program? I'm...
10
by: Stephany Young | last post by:
When one uses the System.Diagnostics.Process.Start method to launch a common or garden Console application, one can set the WindowStyle property of the StartInfo object to ProcessWindowStyle.Hidden...
1
by: janefield2002 | last post by:
Hi there, I have a client-server application that periodically connects to an Access database on a network. My netowrk sometimes goes down and there is an ODBC failure to connect. This results...
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
5
by: Don Li | last post by:
Hi, A web app server package that I'm using includes a bunch of open source UI components (heavy with javascripts). Inevitably it has bugs, e.g. "undefined" is null or not an object. This...
5
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Dear all, I'd like to know if there is any method to minimize command mode window when a console program is running. In my case, there are several console programs which run periodically in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.