Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

getting rid of DOS console window

Posted on 2002-03-15
3
Medium Priority
?
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

688 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