minimize or hide dos window in c++

CU

Platinum Member
Aug 14, 2000
2,415
51
91
I generate a command I need to run in C++, and then call system(cmd) to run it. How can I get it to run the dos window minimized or better yet not show up at all?
 

CU

Platinum Member
Aug 14, 2000
2,415
51
91
How do I know what the window name is to use FindWindow?

I am trying to use ShellExecute now as I can pass it SW_HIDE and that may work if I can figure out how to give it the parameters to my command correctly. I am trying to run the command:
vdub /i script.syl "input file.avi" "output file.avi" > log.txt
The "> log.txt" part is not critical, but I would like to have it. I am having problems with the parameters though. It is running vdub and I can see it load "input file.avi" before the dos windows closes. I don't get an output file or a log file though. It works fine with system(), so I know it works.
 

CU

Platinum Member
Aug 14, 2000
2,415
51
91
Well I wrote out my cmd to a bat file and run that using ShellExecute. That hides it all I see is a virtual dub icon appear for a second in the task bar. I don't think I can stop that because vdub just launches virtual dub and there doesn't seem to be anything I can pass vdub to hide it. The problem I have now is while system() blocked execution, ShellExecute() doesn't. So, I need to find a way to block on it because I would like it to finish before I continue.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,610
4,530
75
Off the top of my head, something like:

system("cmd /c start /min vdub /i script.syl \"input file.avi\" \"output file.avi\" > log.txt");

should get it going in a minimized window. However, unless you can find that window or parse the logfile, you won't know when it's finished.
 

CU

Platinum Member
Aug 14, 2000
2,415
51
91
I got it to work with ShellExecuteEx which gave me a the handle to process, so I could block on that process. Thanks for the help.
 
Sep 29, 2004
18,656
67
91
I had to do this years ago. I wish I remember how I did it, but you should be able to launch the program without having the console appear. I was trying to get the results of ping.exe.

Actually, it might just be because I was writing a windows service at the time and the service mechanism hid the window for me.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
I've never used system() on Windows before. Is the CLI necessary if you're simply using it to run a different process?
 

sao123

Lifer
May 27, 2002
12,653
205
106
Originally posted by: CU
Well I wrote out my cmd to a bat file and run that using ShellExecute. That hides it all I see is a virtual dub icon appear for a second in the task bar. I don't think I can stop that because vdub just launches virtual dub and there doesn't seem to be anything I can pass vdub to hide it. The problem I have now is while system() blocked execution, ShellExecute() doesn't. So, I need to find a way to block on it because I would like it to finish before I continue.

why mixing bat with c++?? most of the things you can do with BAT files can be done programattically.