• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

minimize or hide dos window in c++

  • Thread starter Thread starter CU
  • Start date Start date

CU

Platinum Member
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?
 
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.
 
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.
 
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.
 
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.
 
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.
 
I've never used system() on Windows before. Is the CLI necessary if you're simply using it to run a different process?
 
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.
 
Back
Top