Query the time zone from the command line I want to print the a bottom line with the echo command
this is my try but i get the error
@echo off
set a="tzutil /g"
echo %a%
exit
please help
Query the time zone from the command line I want to print the a bottom line with the echo command
this is my try but i get the error
@echo off
set a="tzutil /g"
echo %a%
exit
please help
If you want to echo the time zone, all you need is:
@echo off
tzutil /g
echo.
pause
Unless you want to have quotes inside your variable, you want to put them before and after your set options like this: set "zone=tzutil /g" instead of having your first double quote after the equals sign. If your goal is to set the output of tzutil /g as a variable, you would do it like this:
@echo off
for /f "tokens=* usebackq" %%A in (`tzutil /g`) do (
set "zone=%%A"
)
echo %zone%
pause
Here you use for /f to loop through the output of a command, then set your variable using the parameter.
echo?Use the following batch file (test.cmd):
@echo off
setlocal
for /f "tokens=*" %%f in ('tzutil /g') do (
echo %%f
)
endlocal
Example usage:
F:\test>test
GMT Standard Time
F:\test>