Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Hide the command prompt for a command line program

Posted on 2004-10-11
4
Medium Priority
?
325 Views
Last Modified: 2008-01-16
I am makign a Win32 command line program and was wondering how to make it just "run in the background" instead of show the command prompt. I figured out how to hide it once it started (using SetConsoleTitle, FindWindow, and ShowWindow) but then the program still shows for a breif time. Specfically, this program runs at login, if that makes any difference.
0
Comment
Question by:thaimin
  • 3
4 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 12276479
Are you using VC++ ?  If so you can change the linker (Project->Settings->Link tab) options to

subsystem:windows (instead of subsystem:console)

and add

/entry:mainCRTStartup

HTH
0
 
LVL 1

Author Comment

by:thaimin
ID: 12277204
Okay, so that works, but leads to another problem. I call some other console apps with the system() command and when I do that, a console shows up (even though they produce no output). Is there a way to make these processes without showing up themselves (I tried CreateProcess() but that does the same thing...). Even when I use CreateProcess with a non-console app (such as notepad) but put it in the CommandLine field it still creates the console. Is there a way to not make this console show up? (also, does the first field on CreateProcess except arguments or just the program name?)

Thanks.
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 12277879
>> Even when I use CreateProcess with a non-console app (such as notepad) but put it in the CommandLine field it still creates the console. Is there a way to not make this console show up?

See http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_10225450.htm (credit to jkr)

>> also, does the first field on CreateProcess except arguments or just the program name?)

According to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createprocess.asp, the second parameter is what you use to specify command line arguments.

HTH
0
 
LVL 19

Accepted Solution

by:
mrwad99 earned 400 total points
ID: 12277891
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question