Unscruffed
Programmer
I have a little console app I wrote called FFMemMon.exe that monitors the memory used by ffmpeg.
I also have another little app called Wait.exe that simply waits x seconds before exiting.
When FFMemMon runs, it attaches to the console and stores the current cursor position. It then starts monitoring the process list and once it detects ffmpeg running, it starts monitoring that processes memory. Every second or so, it prints a status line in the console at the stored cursor location showing the current and peak memory usage for ffmpeg. This is done using the WriteConsoleOutput function.
For this to work, you need to use START /B FFMemMon so that the batch file keeps running - and that's where the problem is.
At the moment, I have a batch file that lloks like this:
The problem is that the startup time for any app is never consistent and sometimes FFMemMon and ffmpeg end up writing their status lines to the same line in the console, when FFMemMon should be 2 lines above ffmpeg.
My hopeful solution is to do away with the whole START /B thing and have FFMemMon spawn itself (passing the cursor location on the command line) and then exit. The second instance would then be the one that runs in the background and printing the status line to the console.
So the batch file would then look like this:
No need for START /B or WAIT.
So my question is: How do I start that second instance within the same console window from VB?
I also have another little app called Wait.exe that simply waits x seconds before exiting.
When FFMemMon runs, it attaches to the console and stores the current cursor position. It then starts monitoring the process list and once it detects ffmpeg running, it starts monitoring that processes memory. Every second or so, it prints a status line in the console at the stored cursor location showing the current and peak memory usage for ffmpeg. This is done using the WriteConsoleOutput function.
For this to work, you need to use START /B FFMemMon so that the batch file keeps running - and that's where the problem is.
At the moment, I have a batch file that lloks like this:
Code:
@ECHO OFF
START /B FFMemMon
WAIT 0.5
ECHO.
ECHO.
FFMPEG ....
The problem is that the startup time for any app is never consistent and sometimes FFMemMon and ffmpeg end up writing their status lines to the same line in the console, when FFMemMon should be 2 lines above ffmpeg.
My hopeful solution is to do away with the whole START /B thing and have FFMemMon spawn itself (passing the cursor location on the command line) and then exit. The second instance would then be the one that runs in the background and printing the status line to the console.
So the batch file would then look like this:
Code:
@ECHO OFF
FFMemMon
ECHO.
ECHO.
FFMPEG ....
So my question is: How do I start that second instance within the same console window from VB?
Last edited: