Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting TimeZone from a Script

504 views
Skip to first unread message

Joseph Morales

unread,
Feb 8, 2005, 6:10:36 AM2/8/05
to
Is there any supported interface that a VBScript can use to set the system
timezone? (I mean, not just by hacking the registry.)

I've experimented with a couple of WMI features that don't seem to work. For
example, the Win32_ComputerSystem object has a CurrentTimeZone property that
is read/write, but when I write a value to it, the computer's actual
timezone doesn't actually get changed. I did set the
"SeSystemTimePrivilege", so I don't think the problem was insufficient
privileges. Instead, this appears to be one of many WMI properties that are
writeable but do not have any actual effect on the system.

I thought the Win32_OperatingSystem.SetDateTime method might work, as the
last three digits specify an offset for the timezone. However, on
experimenting with it, it appears that those digits only affect the way the
time value is interpreted, without changing the current timezone on the
system.

I'm on XP SP2, and the script needs to work on XP and W2K3.

Thanks in advance for any suggestions.


Torgeir Bakken (MVP)

unread,
Feb 8, 2005, 8:50:33 PM2/8/05
to
Joseph Morales wrote:

Hi

Time zone change using the command line utility Control.exe
(Win2k/WinXP/Win2k3):

Control.exe TIMEDATE.CPL,,/Z (GMT-08:00) Pacific Time (US & Canada); Tijuana

alternatively:
RUNDLL32.EXE SHELL32.DLL,Control_RunDLL TIMEDATE.CPL,,/Z (GMT-08:00) Pacific
Time (US & Canada); Tijuana

where '(GMT-08:00) Pacific Time (US & Canada); Tijuana' is the timezone to
be set.

Input value behind /Z is from the Display value under the registry key
'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones'

You can use the Std value in those registry keys as well, this is equivalent
with "(GMT-08:00) Pacific Time (US & Canada); Tijuana":

Control.exe TIMEDATE.CPL,,/Z Pacific Standard Time

--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Joseph Morales

unread,
Feb 9, 2005, 5:40:44 PM2/9/05
to
> Time zone change using the command line utility Control.exe
> [ etc ]

Thanks! This works great and will be very handy.


Joseph Morales

unread,
Feb 9, 2005, 8:44:46 PM2/9/05
to
Hmm, here's the next problem. How to set or reset the "Automatically adjust
clock for daylight saving changes" from a script? Is there a parameter for
this that can be passed to timedate.cpl?

Thanks!


vard...@gmail.com

unread,
Jul 5, 2012, 8:29:24 AM7/5/12
to
Thank you Joseph :)
Worked fine with GMT+1 as well.

C:\WINDOWS\system32>Control.exe TIMEDATE.CPL,,/Z (GMT+01:00) Amsterdam, Berlin,
Bern, Rome, Stockholm, Vienna
0 new messages