Created
December 29, 2022 20:49
-
-
Save zommuter/677589dc001755d0c74f09c573f68c35 to your computer and use it in GitHub Desktop.
Update YEAR, MONTH and DAY Windows environment variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM Slight modification of https://stackoverflow.com/a/33402280/321973 | |
for /F "skip=1 delims=" %%F in (' | |
wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE | |
') do ( | |
for /F "tokens=1-3" %%L in ("%%F") do ( | |
set DAY=0%%L | |
set MONTH=0%%M | |
set YEAR=%%N | |
) | |
) | |
set DAY=%DAY:~-2% | |
set MONTH=%MONTH:~-2% | |
setx YEAR %YEAR% > NUL | |
setx MONTH %MONTH% > NUL | |
setx DAY %DAY% > NUL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment