Reputation: 43
So I'm trying to create a batch file to change the pc's timezone according to the current timezone on it (Working on Win 8.1 btw). here's what I have so far:
set current="timezone value"
if %current%=="S.A. Pacific Standard Time" TZUTIL s/"China Standard Time" else TZUTIL s/"S.A. Pacific Standard Time"
How do I get the current timezone value of my pc so I can set %current% right? Is there another way to do it without using TZUTIL?, how do you recommend me do it?
Upvotes: 1
Views: 137
Reputation: 2710
for /f "delims=" %%a in ('TZUTIL /g') do set "current=%%a"
echo %current%
Also your command has incorrect switch and missing quotes in comparison
if "%current%"=="S.A. Pacific Standard Time" (
TZUTIL /s "China Standard Time"
) else (
TZUTIL /s "S.A. Pacific Standard Time"
)
Upvotes: 1