473,396 Members | 2,139 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,396 software developers and data experts.

system() and no console ?

I'm very new to C and am having a hard time figuring out how to pass a
command to the underlying OS so as it doesn't keep the console window
open. By double-clicking from Windows Explorer, I want the other
process to just spawn and the console to close.

For example, on Windows XP, I make the following call:

system(my_command);

where my_command = 'my_program.exe'.
But in Windows the console window stays open until my_program.exe exits.
I guess that makes sense but how would I change my_command or is there
an alternative to system() that would spawn a new process and then
immediately return so my application can complete and close the console?
I tried 'my_program.exe &', but that didnt work either.

Thanks!
Nov 15 '05 #1
6 3197
In article <bd********************@comcast.com>, Bugs <do**@spam.me> wrote:
I'm very new to C and am having a hard time figuring out how to pass a
command to the underlying OS so as it doesn't keep the console window
open. By double-clicking from Windows Explorer, I want the other
process to just spawn and the console to close.


Anything to do with underlying OS's and console windows is outside the
scope of C itself. You should ask the question in a Windows newsgroup.
--
Look out, there are llamas!
Nov 15 '05 #2
Walter Roberson wrote:

Anything to do with underlying OS's and console windows is outside the
scope of C itself. You should ask the question in a Windows newsgroup.


My apologies, I'll ask in the Windows newsgroup. I thought the answer
might be an alternative C library call instead of system() ?
Thanks
Nov 15 '05 #3
On Thu, 28 Jul 2005 10:09:28 -0700, Bugs <do**@spam.me> wrote in
comp.lang.c:
Walter Roberson wrote:

Anything to do with underlying OS's and console windows is outside the
scope of C itself. You should ask the question in a Windows newsgroup.


My apologies, I'll ask in the Windows newsgroup. I thought the answer
might be an alternative C library call instead of system() ?
Thanks


Two things.

Try the Windows group news:comp.os.ms-windows.programmer.win32, it is
excellent and has a good traffic level and response rate.

And there is no alternative standard C library call to system(). This
is the one and only function that allows a C program to possibly
interact with other executables. All others are non-standard,
platform specific extensions. The methods you find for Windows will
not work at all on Linux or a Macintosh.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 15 '05 #4
In article <ML********************@comcast.com>, Bugs <do**@spam.me> wrote:
Walter Roberson wrote:
Anything to do with underlying OS's and console windows is outside the
scope of C itself. You should ask the question in a Windows newsgroup.

My apologies, I'll ask in the Windows newsgroup. I thought the answer
might be an alternative C library call instead of system() ?


Sorry, doesn't exist.

If it were Unix then there are techniques involving multiple shell levels
and 'nohup' -- or better yet, POSIX extensions such as setsid()
and O_NOCTTY when opening devices. But those are OS (or at least POSIX)
specific, not part of C, and I have idea what the Windows paradigm would be.

--
"This was a Golden Age, a time of high adventure, rich living and
hard dying... but nobody thought so." -- Alfred Bester, TSMD
Nov 15 '05 #5
Thanks to everyone who responded.
FYI - I found a workaround:
As I'm passing system() a platform-specific WinXP command, I changed the
command from 'myprogram.exe' to 'start myprogram.exe' and that worked
fine. The console still pops up but for just an instant.
Thanks again.
Nov 15 '05 #6
Bugs <do**@spam.me> writes:
Thanks to everyone who responded.
FYI - I found a workaround:
As I'm passing system() a platform-specific WinXP command, I changed
the command from 'myprogram.exe' to 'start myprogram.exe' and that
worked fine. The console still pops up but for just an instant.


<COMPLETELY_OT>
START /?
prints a usage message that you might find illuminating.
</COMPLETELY_OT>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
4
by: William McIlroy | last post by:
Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement.. using...
1
by: Stephanie Stowe | last post by:
Hi. I am trying to read information out of the IIS metabase (v5.1). Observe the following code: using System; using System.DirectoryServices; using System.Reflection; namespace ADSI1 {...
0
by: Tim Wagaman | last post by:
I an having issuses with a loop I am running to keep checking for messages coming across our line. The goal: Listen for messages on port 5001 and print the messages into a text file. The port...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
20
by: djc | last post by:
I get this *intermittently* on a utility I am working on. I don't know whats going on but here are a few points about it: - using VS 2005, running on xp sp2 - program uses multiple threadpool...
1
by: =?Utf-8?B?QnJpYW4gQ29iYg==?= | last post by:
This code is contained in one source file in VS 2005 project: using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace ReflectionTest {...
1
by: nygiantswin2005 | last post by:
Hi I am trying to resolve this bug that I have in this application. The code is below. It will generate this Exception System.UnauthorizedAccessException: Access to the path is denied. at...
8
by: =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post by:
Hi, I created a web service and hosted it in Windows Services. It is working fine. Now I am trying to implement the X509 certificates for message layer security. But it is throwing the following...
30
by: Yorian | last post by:
Hey, Although I've been using classes and object for quite a while now I've never actually programmed proper OO code yet. It ofcourse depends on what you call proper OO code. I have been...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.