Pou Thapioume
Pou Thapioume

Reputation: 5

CMD.exe get first day of the month

Using cmd batch file can i get first day of month and run an action? For example every first day of the month shutdown the pc.

Thanks in advance!

Upvotes: 0

Views: 2378

Answers (1)

Stephan
Stephan

Reputation: 56155

for german date format: echo 01%date:~2%. For american format: echo %date:~0,3%01%date:~5%

or use a language independent solution:

for /F "delims=" %%i in ('wmic path Win32_LocalTime get month^,year /value^|find "="') doset /a %%i
set DatTim=01.%month%.%year%
REM adapt to your needed format

or in your special case:

for /F "delims=" %%i in ('wmic path Win32_LocalTime get day /value^|find "="') do set /a %%i
if %day%==1 (
   rem your commands
)

Upvotes: 1

Related Questions