einstein1969 wrote:second mod:
Code: Select all
start "" /B /WAIT cmd /V:ON /Q /C"cmd /V:ON /Q /C^"for /L %%k in (1,0,1) do if "^!time:~9,2^!"=="99" (exit) else (if "^!time:~9,2^!"=="00" (exit))"" & call echo %%time%% %time% !time! ok"
result:
Code: Select all
18:13:22,99 18:13:21,99 !time! ok"
but i think that is no good because i need using "call echo". And there is an " at the end.
I want that the nested cmd exit and than "echo" run without "call".
What should I change?
Since you appended to the command it works in that
Code: Select all
call echo %%time%% %time% !time! ok
the time the command is executed is displayed "echo %time%".
the time the command is finished is displayed "call echo %%time%%".
but this obviously doesn't "!time!" as you forgot to enable delayed expansion
Code: Select all
@echo off
echo.time.str=%time%_
cmd /V:ON /Q /C^"^
for /L %%k in (^
1,0,1^
) do if "!time:~9,2!"=="99" (^
exit^
)else if "!time:~9,2!"=="00" (^
exit^
)^
"
echo.time.end=%time%_
pause
exit /b
Code: Select all
time.str=19:35:25,28_
time.end=19:35:26,00_
Druk op een toets om door te gaan. . .
einstein1969 wrote:And there is an " at the end.
If you count the quotes you see that you add a double quote at the end of the line but your command inside a child cmd session is already complete
Code: wrote:start "" /B /WAIT cmd /V:ON /Q /C"cmd /V:ON /Q /C^"for /L %%k in (1,0,1) do if "^!time:~9,2^!"=="99" (exit) else (if "^!time:~9,2^!"=="00" (exit))"" & call echo %%time%% %time% !time! ok"
This works since the previous quote is consumed by the child session.
Code: Select all
@echo off
cmd /V:ON /Q /C"cmd /V:ON /Q /C^"echo.^>nul"" & call echo %%time%% %time% !time! ok"
cmd /V:ON /Q /C"cmd /V:ON /Q /Cecho.a!^>nul" &echo.b! &call echo %%time%% %time% !time! ok"
pause
exit /b
Code: Select all
19:48:54,75 19:48:54,64 !time! ok"
b!
19:48:54,87 19:48:54,75 !time! ok"
Btw;
What is the point of running a cmd session inside a cmd session ?