Page 1 of 1

Waiting for previous command to finish..

Posted: 12 Feb 2017 20:30
by shashank.gece
THIS IS MY CODE.
RIGHT NOW I AM USING THE DELAY OPTION.
INSTEAD OF THE DELAY COMMAND CAN I USE ANOTHER COMMAND WHICH WILL WAIT FOR THE PREVIOUS COMMAND TO FINISH AND THEN RUN THE NEXT COMMAND.


Code: Select all

@echo off

rem this file copies the name from the text file to the excel file
pushd %~dp0
start /b "" cscript final.vbs
echo. excel is being edited

rem this will wait

echo. PLEASE WAIT..............
CHOICE /N /C YN /T 5 /D Y >NUL
echo. Excel file is edited

rem this will copy the file from out folder to pdx folder
pushd %~dp0
start /b "" cscript CopyMot.vbs
echo.file is being copied

rem this will wait

echo. PLEASE WAIT...........
CHOICE /N /C YN /T 5 /D Y >NUL
echo. file is copied

rem this will run the macro

pushd %~dp0
start /b "" cscript Shashank.vbs
echo. PDX is being created

rem this will wait and kill hexview 1

echo. Closing Hexview1
CHOICE /N /C YN /T 3 /D Y >NUL
pushd %~dp0
start /b "" cscript KillProcess.vbs
echo. Hex view 1 is closed

rem this will wait and kill hexview 2

echo. Closing Hexview2
CHOICE /N /C YN /T 3 /D Y >NUL
pushd %~dp0
start /b "" cscript KillProcess.vbs
echo. Hex view 2 is closed

rem this will wait

echo. PLEASE WAIT..............
CHOICE /N /C YN /T 40 /D Y >NUL
echo. Pdx is created

rem this will copy the pdx and place it in out folder

pushd %~dp0
start /b "" cscript MovePdx.vbs
echo. Moving pdx file to out folder....

rem this will wait

echo. PLEASE WAIT..............
CHOICE /N /C YN /T 3 /D Y >NUL
echo. File is moved to the out folder

rem this will close excel
pushd %~dp0
start /b "" cscript KillExcel.vbs
echo. PROCESS COMPLETE  !

PAUSE

Re: Waiting for previous command to finish..

Posted: 12 Feb 2017 22:09
by Squashman
You don't need to use the START command. Just use cscript.exe directly. You can use the /WAIT option with the START command but in your case you don't even need to use the START command.

For future posts please do not post in all capital letters and please use code tags around your code.

Re: Waiting for previous command to finish..

Posted: 12 Feb 2017 22:24
by shashank.gece
So if I don't use (( start /b "" )) and directly use cscript, will the next command wait for the previous command to wait?

Re: Waiting for previous command to finish..

Posted: 13 Feb 2017 06:13
by penpen
The batch interpreter nearly always processes one command after another.
The only exception is the pipe operator "cmd1 | cmd2", where cmd1 and cmd2 are running at the same time.

So the batch interpreter also fully processes the "start" command before executing the next command.
But the "start" command doesn't wait, except if you use the "/wait" switch.
(Beside this the "start" command also won't wait when using "/b".)


penpen

Re: Waiting for previous command to finish..

Posted: 13 Feb 2017 07:37
by Squashman
shashank.gece wrote:So if I don't use (( start /b "" )) and directly use cscript, will the next command wait for the previous command to wait?

Yes. That is what I was inferring.

Re: Waiting for previous command to finish..

Posted: 13 Feb 2017 17:41
by shashank.gece
Thanks !!
It worked ....