Skip to content

Instantly share code, notes, and snippets.

@hofs
hofs / getdate.cmd
Created December 7, 2016 12:34
Auto MySQL Backup For Windows Servers By Matt Moeller (updated to work with WMIC)
@ECHO OFF
:: Check WMIC is available
WMIC.EXE Alias /? >NUL 2>&1 || GOTO s_error
:: Use WMIC to retrieve date and time
FOR /F "skip=1 tokens=1-6" %%G IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') DO (
IF "%%~L"=="" goto s_done
Set _yyyy=%%L
Set _mm=00%%J
Set _dd=00%%G