Im trying to make a script that the user need to fill 3 spaces in the same line. Is it possibile?
For example filling a date: 25/02/2019
in this way: day here / month here / year here
Not line by line.
The normal way is that:
set /p "dd=Type the Day: "
set /p "mm=Type the Month: %dd% / "
set /p "aa=Type The Year: %dd% / %mm% / "
And the result will be: 22/05/2019
But i want put these 3 set /p
in one single line, filling only this single line.
I tried this way:
set dd=%%a
set mm=%%b
set aa=%%c
set /p "test= "!dd! !mm! !aa!
echo %%a / %%b / %%c
pause
Also tried:
set /p "dd=Type the day: " / &set /p "mm=Type the month " &set /p "aa=Type the year "
But unfortunatelly didn't worked. The second way worked line by line.
Edit 1:
Follow my final script to change the Windows date by batch command:
@echo off
setlocal enableextensions
setlocal EnableDelayedExpansion
cd /d "%~dp0"
mode 42,12
:begin
cls
echo ------------------------------------------
echo MUDAR A DATA DO WINDOWS
echo ------------------------------------------
echo( &echo(
echo 1 - Escolher a data & echo( &echo 2 - Retornar para a data atual
echo( & echo( &echo(
choice /n /c:12 /m "Digite uma op‡Æo:"%1
call :lab%errorlevel%
:lab 1
cls
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
set /P "=Digite a data: / / !CR!Digite a data: " < nul
call :GetDigits 2 3 Day=
set /P "=.%BS% / " < nul
call :GetDigits 2 1 Mon=
set /P "=.%BS% / " < nul
call :GetDigits 4 2 Year=
echo/
echo/
net stop w32time >nul 2>nul
sc config w32time start= disabled >nul 2>nul
date %Day%-%Mon%-%Year% <nul && (
echo Data modificada: %Day%/%Mon%/%Year%
timeout /nobreak /t 2 >nul 2>nul
goto begin
) || (
cls & echo Erro ao mudar a data.
echo( &echo( &echo(
pause
goto begin
)
:GetDigits HowMany FirstLimit Result=
setlocal EnableDelayedExpansion
set "digits=123456789"
set "%3="
choice /C "0!digits:~0,%2!" /N > nul
set /A digit=%errorlevel%-1
set /P "=%digit%" < nul
set "%3=!%3!%digit%"
for /L %%i in (2,1,%1) do (
choice /C "0%digits%" /N > nul
set /A digit=!errorlevel!-1
set /P "=!digit!" < nul
set "%3=!%3!!digit!"
)
for %%a in (!%3!) do endlocal & set "%3=%%a"
exit /B
:lab2
sc config w32time start= demand >nul
net start w32time >nul 2>nul
cls & w32tm /resync >nul 2>&1
echo Data atual retornada.
timeout /nobreak /t 2 >nul 2>nul
cls & goto begin
No comments... ;)
@echo off
setlocal EnableDelayedExpansion
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
set /P "=Enter the date: DD / MM / YYYY!CR!Enter the date: " < nul
call :GetDigits 2 3 Day=
set /P "=.%BS% / " < nul
call :GetDigits 2 1 Mon=
set /P "=.%BS% / " < nul
call :GetDigits 4 2 Year=
echo/
echo/
echo Result: %Day%/%Mon%/%Year%
goto :EOF
:GetDigits HowMany FirstLimit Result=
setlocal EnableDelayedExpansion
set "digits=123456789"
set "%3="
choice /C "0!digits:~0,%2!" /N > nul
set /A digit=%errorlevel%-1
set /P "=%digit%" < nul
set "%3=!%3!%digit%"
for /L %%i in (2,1,%1) do (
choice /C "0%digits%" /N > nul
set /A digit=!errorlevel!-1
set /P "=!digit!" < nul
set "%3=!%3!!digit!"
)
for %%a in (!%3!) do endlocal & set "%3=%%a"
exit /B