Solved

getting rid of DOS console window

Posted on 2002-03-15
3
381 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 50 total points
ID: 6869563
What's in the batch file? Try putting "exit" as the last command.

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 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.
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now