Batch file parallel processing / routing

November 24, 2010 at 08:54:47
Specs: Windows 7, plenty

I'm running 64b Win7. I have a batch file (.bat) that I use to shut the machine down each night, that optionally backs up data and then which calls CCleaner. After CCleaner finishes the system shuts down.

Everything works fine. But here's what I want to do. I want to start another program when the script opens, have it run in parallel to the backup and cleaning operation, and have its completion mutually critical, with the backup/cleaning operations, to the machine shutting down.

IOW, I want to parallel process, but I want the final shut down to be dependent on both processes completing. I don't want the system to shut down until both are finished.

Currently I call the first program via a Start command. The problem is that the machine shuts down when the cleaning process is done, regardless of whether the first program is finished.

It's a logical problem that I haven't been able to find a batch tool to solve yet. My other option might be to go to an autoit script.


See More: Batch file parallel processing / routing

Report •

November 24, 2010 at 09:17:30
I think if you create a loop that monitors activity it should work...
for example, the shutdown script would monitor if the other BATs are still running...if not then it would engage shutdown.

Report •

November 24, 2010 at 09:55:44
Okay, this sounds good. So far I've got this:

tasklist /FI "IMAGENAME eq autoit3_x64.exe" 2>NUL | find /I /N "autoit3_x64.exe">NUL
if "%ERRORLEVEL%"=="0" echo Programm is running

(Courtesy of: Chaosmaster )

Now I need find how to set up a loop that tests periodically, and I should be home.

Thanks much,

Report •

November 25, 2010 at 06:19:22
Here's the gist of what I worked up. Working fine on Win7:

@echo off

::parallel process
Start "" notepad

::trunk process
"c:\users\paul\desktop\us time zone map.gif"

:: test for parallel process to die before launching 3rd process

echo testing...
tasklist /FI "IMAGENAME eq notepad.exe" 2>NUL | find /I /N "notepad.exe">NUL
if "%ERRORLEVEL%"=="0" goto WAIT

:final phase
echo 3rd process
goto EOF

echo waiting...
timeout /t 5 /nobreak > NUL


Report •

Related Solutions

February 8, 2011 at 09:07:26
This is a test reply to check notifications. Sorry for the bump.

Report •

Ask Question