Groups | Blog | Home
all groups > dotnet framework > may 2008 >

dotnet framework : Changing the timezone on Vista SP1



Marco Shaw [MVP]
5/29/2008 8:54:09 AM
I've searched around in the Windows SDK. Is there a .NET class that can
help me to change the timezone setting on a Vista machine?

Marco

renegade
5/29/2008 1:13:01 PM


[quoted text, click to view]

Marco:

If I understand your question, you wish to change the time zone on your
Vista machine. Easily done--just right click the time in the lower right
corner and a pop-up menu will appear. One of the choices is Adjust
Time/Date. Click on that choice and you will geta screen to make the cahnges
greatbarrier86
5/29/2008 3:05:17 PM
Renegade,

What marco and i are looking for is a way to do this through a script. It
needs to be automated for deployment purposes.

[quoted text, click to view]
Jeroen Mostert
5/29/2008 7:32:30 PM
[quoted text, click to view]
Short answer: no. In fact, there's no way to change the system time at all
from .NET, barring P/Invoking. It's one of those tasks that's rare and
privileged, so the managed world doesn't expose it. Typically the
functionality should be centralized -- either locally and manually (the
Date and Time applet) or managed from Active Directory and/or deployed
scripts. If individual applications start messing with it, things can get ugly.

You can do it from Win32 with SetTimeZoneInformation(), and of course you
can import and call that from C#, but there's no managed equivalent.

--
J.
Marco Shaw [MVP]
5/29/2008 9:33:13 PM
[quoted text, click to view]

Yes, I was just trying to determine if there was a .NET class that might
help...

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
Jeff Winn
5/31/2008 12:06:30 AM
Nope, but like Jeroen said earlier you can always use p/invoke to do it.
However, on Vista it's probably going to require elevated privileges.

http://www.pinvoke.net/default.aspx/kernel32/SetTimeZoneInformation.html

Here's a link that might at least get you started with what you'll need to
do. Good luck!

[quoted text, click to view]
AddThis Social Bookmark Button