How can I set the timezone in Windows from command line or from a batch file?
Do I need to use powershell or cscript?
How can I set the timezone in Windows from command line or from a batch file?
Do I need to use powershell or cscript?
The command line utility that helps you change the time zone in Windows 7 is tzutil.exe
and is known as Windows Time Zone Utility. This is a great tool for all the people who prefer working from the command prompt.
Use the /s
parameter to set the time zone:
tzutil /s "universal standard time"
Use the /g
parameter to get the time zone:
tzutil /g
Use the /l
parameter to list the valid time zones.
tzutil /l
[source]
If anyone still uses Windows XP (as I do):
Step 1:
You can use the following command line, e.g. in the "Execute" window (cmd):
Control.exe TIMEDATE.CPL,,/Z W. Europe Standard Time
Where "W. Europe Standard Time" is, not really surprisingly, for Western Europe. Other possible values are e.g.
and so on. A list of possible values can be found here (although for Windows Vista, but it seems most values are the same):
https://technet.microsoft.com/en-us/library/cc749073%28v=ws.10%29.aspx
Step 2
In order to run the above command from a shortcut, you can do the following:
Create a new shortcut (e.g. in Windows explorer, right-click anywhere in an empty area, and choose "New shortcut") and give it the following value (by entering the code into the window that opens, or as "target" in the accordingly named field):
C:\Windows\System32\cmd.exe /c Control.exe TIMEDATE.CPL,,/Z W. Europe Standard Time
(The example uses W. Europe Standard Time; change this to your liking)
Calling this shortcut (i.e. clicking the Icon) immediately changes the timezone.
For my needs, I created two such shortcuts, one setting the timezone to Western Europe, the other setting it to Eastern Europe, as these are the locations where I am working regularly.
(Source for Step 2: Run a Command Prompt command from Desktop Shortcut)
Here is another answer to the initial question, related to Windows 7. This solution is completely based on Ionica Bizau's first contribution (see above). Essentially, I just added a step-by-step instruction for creating a batch file.
To create a batch file for setting time zones:
1) Create a text file in any text editor (PSPad, Notepad++, Notepad or whatever)
2) In the text file, write just one line of code. E.g. write
tzutil /s "GTB Standard Time"
which will set the time zone for Sofia, Bucharest, etc. Or use
tzutil /s "W. Europe Standard Time"
for places in the geographical longitudes of Amsterdam, Brussels, etc.
3) Save the file with a meaningful name such as "Set_TimeZone_W-Europe.bat". Make sure that the filetype suffix is ".bat". Save it at any place you like in your file system. You may choose your "Desktop" folder so to make the file available from your desktop screen.
4) That's it. Double-clicking the icon will trigger the (minimalistic) programme code to be executed, i.e. the system time will be set as desired.
Note: For my purposes, I made two such files, one for Western Europe, one for South East Europe, which are places I visit regularly.
If you need other time zones, look them up how they are named as follows:
a) Open the "Execute" window (cmd)
b) Type "tzutil /l" (without the quotation marks) and hit "return". This will display a list of available time zones.