change timezone based on number

bbimis
bbimis used Ask the Experts™
on
lets say i have a file zones.txt
inside this file I have the following
1 central standard time
2 central standard time
3 eastern standard time

how via a bat script can I read that file and pass it to tzutil

basically in the script it will say type location number so i hit 3
it will then search the text file and issue the command tzutil /s "Eastern Standard Time"

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
For the fun of it, here's a complete menu that's built based on the zones.txt. It only displays and accepts the values found in there. It's in test mode and will only display the tzutil command it would normally run; remove the uppercase ECHO in line 25 to run it for real.
@echo off
setlocal enabledelayedexpansion
REM *** %~dp0 expands to the script's Drive and Path, including a trailing backslash.
set TZFile=%~dp0zones.txt

for /f "tokens=1 delims=" %%a in ('set Menu[ 2^>NUL') do (set %%a=)
for /f "tokens=1* delims= " %%a in ('type "%TZFile%"') do (set Menu[%%a]=%%b)
:MenuLoop
cls
echo =============================================
echo       Time zone selection
echo =============================================
for /f "tokens=2* delims=[]=" %%a in ('set Menu[') do (echo [%%a] %%b)
echo ----------
echo [X] Exit
echo ----------
echo.
set /p Choice=Please enter your choice: 
if "%Choice%"=="" goto MenuLoop
if "%Choice: =%"=="" goto :MenuLoop
if /i "%Choice%"=="X" goto :eof
if not defined Menu[%Choice%] goto MenuLoop
set TimeZone=!Menu[%Choice%]!
echo Time zone picked: %TimeZone%
ECHO tzutil.exe /s "%TimeZone%"

Open in new window

Author

Commented:
thank you so much i can use this as a baseline of what i'm trying to do.

Author

Commented:
just curious where is the zones.txt file at so i can look at its format ?
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
The format is as described in your question.

Author

Commented:
oh okay cool thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial