Reputation: 4496
Here's my batch file:
@echo off
set rdslist=rds-instance-1 rds-instance-2
:retryaction
set /P action=Would you like to (1)start or (2)stop these instances %rdslist%:
IF %action%==1 (
set command=start
goto :start
)
IF %action%==2 (
set command=stop
goto :start
)
goto :retryaction
:start
(for %%a in (%rdslist%) do (
aws rds %command%-db-instance --db-instance-identifier %%a
))
pause
It doesn't pause after I run it, but if I place the pause
before or inside the for loop it pauses.
Upvotes: 2
Views: 914
Reputation: 14305
aws
is another script, not a program. When a batch script executes another batch script without using the call
command, program flow is permanently transferred to that second script and does not return to the first script upon completion. When call
is used, the second script is run and then flow is returned to the parent script.
Change your for
loop to
for %%a in (%rdslist%) do (
call aws rds %command%-db-instance --db-instance-identifier %%a
)
so that your initial script will keep running; otherwise, the script stops after the first instance is completed.
Upvotes: 1