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

x
?
Solved

getting rid of DOS console window

Posted on 2002-03-15
3
Medium Priority
?
391 Views
Last Modified: 2008-02-01
I start a process using CreateProcess as follows, which starts with a minimized DOS console window which, in turn, starts a GUI. I want the console window closed automatically when the GUI is closed. I tried the following code. It doesn't work.
----------------------------------
CreateProcess(NULL,"cmd.exe /c start /min test.bat",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&StartInfo,&pInfo);
HANDLE hp=pInfo.hProcess;
LPDWORD pExitCode=NULL;
GetExitCodeProcess(hp, pExitCode);
ExitProcess(*pExitCode);
----------------------------------
0
Comment
Question by:j4months
3 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 6869245
What is your "STARTUP_INFO" struct like?

It should be

 STARTUPINFO siStartInfo;

    // Set up the start up info struct.
    ZeroMemory(&siStartInfo,sizeof(STARTUPINFO));
    siStartInfo.cb = sizeof(STARTUPINFO);
    siStartInfo.dwFlags = STARTF_USESHOWWINDOW;
    siStartInfo.wShowWindow = SW_HIDE;
0
 

Author Comment

by:j4months
ID: 6869433
I modified the STARTUPINFO as you described, it didn't make a difference..
actually my problem is not at the startup. it's when I close the GUI window..
0
 
LVL 1

Accepted Solution

by:
allym earned 200 total points
ID: 6869563
What's in the batch file? Try putting "exit" as the last command.

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

886 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