I want to initiate a ROBOCOPY process if EXCEL is running in my System.
To do this, I have created the following .txt file –
_________________________________________________________________________________________________________________________________________________________________
echo off
tasklist /fi "IMAGENAME eq *excel*" /fi "STATUS eq running"
if errorlevel 1 (exit)
( robocopy c:\users\neil\AAWorkingModules d:\excelSynch\%date:~10,4%%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%%time:~6,2%\ /e /b /xx /xo /copyall /xf ~$*.* /im /mot:5 /np /log+:d:\excelSynch\log\%date:~10,4%%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%%time:~6,2%.log )
exit
__________________________________________________________________________________________________________________________________________________________________
N.B. The ROBOCOPY process works exactly as I want – tested separately.
I then created a .bat file from this .txt file, and a Shortcut for the .bat file.
My Task Scheduler job then runs that Shortcut.
However, the TASKLIST process does not work – i.e. whether or not EXCEL is running, the ROBOCOPY command is not executed.
The scheduled process keeps running until it is ended manually in Task Scheduler.
Please help with corrections for my coding of the TASKLIST process, or any other errors I have made.
To do this, I have created the following .txt file –
_________________________________________________________________________________________________________________________________________________________________
echo off
tasklist /fi "IMAGENAME eq *excel*" /fi "STATUS eq running"
if errorlevel 1 (exit)
( robocopy c:\users\neil\AAWorkingModules d:\excelSynch\%date:~10,4%%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%%time:~6,2%\ /e /b /xx /xo /copyall /xf ~$*.* /im /mot:5 /np /log+:d:\excelSynch\log\%date:~10,4%%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%%time:~6,2%.log )
exit
__________________________________________________________________________________________________________________________________________________________________
N.B. The ROBOCOPY process works exactly as I want – tested separately.
I then created a .bat file from this .txt file, and a Shortcut for the .bat file.
My Task Scheduler job then runs that Shortcut.
However, the TASKLIST process does not work – i.e. whether or not EXCEL is running, the ROBOCOPY command is not executed.
The scheduled process keeps running until it is ended manually in Task Scheduler.
Please help with corrections for my coding of the TASKLIST process, or any other errors I have made.