![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
Update on changing TimeZone in Vista via script
Does anyone have an update on whether this is possible. I brought it up a
while ago and the xp method, using Control TimeDate.cpl does not work. The Win32_TimeZone shows some methods such as ConvertFrom/ToDateTime, but i'm not sure if they can do anything with the timezone. thanks, Jason |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
greatbarrier86 wrote:
> Does anyone have an update on whether this is possible. I brought it up a > while ago and the xp method, using Control TimeDate.cpl does not work. The > Win32_TimeZone shows some methods such as ConvertFrom/ToDateTime, but i'm not > sure if they can do anything with the timezone. > > thanks, > Jason Well, there's this: http://www.microsoft.com/technet/scr...ista/wmi1.mspx "...read or set the current time zone (offset from Universal Time Coordinate)..." Now that's only the offset it seems, so "-180" for GMT-3. I don't know if it would actually change the timezone displayed like ADT. Oddly, trying this on Vista SP1: $wmi=gwmi win32_computersystem $wmi.currenttimezone=-240 $wmi.put() Returns: PS > $wmi.put() Exception calling "Put" with "0" argument(s): "Generic failure " At line:1 char:9 + $wmi.put <<<< () PS > I searched around a bit, and don't see a solution/explanation of the error. Maybe this could be done directly with wmic, but I'm not too familiar with its syntax, and can't look at this right now. Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
Marco,
I did some rooting around and discovered that CurrentTimeZone is part of the OperatingSystem class and not the Computersystem class. After changing it, the put() did not error out. "Marco Shaw [MVP]" wrote: > greatbarrier86 wrote: > > Does anyone have an update on whether this is possible. I brought it up a > > while ago and the xp method, using Control TimeDate.cpl does not work. The > > Win32_TimeZone shows some methods such as ConvertFrom/ToDateTime, but i'm not > > sure if they can do anything with the timezone. > > > > thanks, > > Jason > > Well, there's this: > http://www.microsoft.com/technet/scr...ista/wmi1.mspx > > "...read or set the current time zone (offset from Universal Time > Coordinate)..." > > Now that's only the offset it seems, so "-180" for GMT-3. I don't know > if it would actually change the timezone displayed like ADT. > > Oddly, trying this on Vista SP1: > $wmi=gwmi win32_computersystem > $wmi.currenttimezone=-240 > $wmi.put() > > Returns: > PS > $wmi.put() > Exception calling "Put" with "0" argument(s): "Generic failure " > At line:1 char:9 > + $wmi.put <<<< () > PS > > > I searched around a bit, and don't see a solution/explanation of the error. > > Maybe this could be done directly with wmic, but I'm not too familiar > with its syntax, and can't look at this right now. > > Marco > > -- > Microsoft MVP - Windows PowerShell > http://www.microsoft.com/mvp > > PowerGadgets MVP > http://www.powergadgets.com/mvp > > Blog: > http://marcoshaw.blogspot.com > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
greatbarrier86 wrote:
> Marco, > > I did some rooting around and discovered that CurrentTimeZone is part of the > OperatingSystem class and not the Computersystem class. After changing it, > the put() did not error out. Cool. It doesn't error out for me either, but doesn't update the property either when I re-issue get-wmiobject to retrieve the object again. Can you confirm? Marco |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
Marco,
Try again. It seems to occur if you keep doing it, except this time it will say "Value Out of Range" "Marco Shaw [MVP]" wrote: > greatbarrier86 wrote: > > Marco, > > > > I did some rooting around and discovered that CurrentTimeZone is part of the > > OperatingSystem class and not the Computersystem class. After changing it, > > the put() did not error out. > > Cool. It doesn't error out for me either, but doesn't update the > property either when I re-issue get-wmiobject to retrieve the object again. > > Can you confirm? > > Marco > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
greatbarrier86 wrote:
> Marco, > > Try again. It seems to occur if you keep doing it, except this time it will > say "Value Out of Range" I tried several times: no change for me... Marco |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
Well, if you can't figure it out, i guess we're out of luck?
There has to be some way...my best guess would be to do something with AutoIT. "Marco Shaw [MVP]" wrote: > greatbarrier86 wrote: > > Marco, > > > > Try again. It seems to occur if you keep doing it, except this time it will > > say "Value Out of Range" > > I tried several times: no change for me... > > Marco > |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
greatbarrier86 wrote:
> Marco, > > I did some rooting around and discovered that CurrentTimeZone is part of the > OperatingSystem class and not the Computersystem class. After changing it, > the put() did not error out. OperatingSystem is read-only though: http://msdn.microsoft.com/en-us/libr...39(VS.85).aspx ComputerSystem is read/write, but still, something is off: http://msdn.microsoft.com/en-us/libr...02(VS.85).aspx Marco |
|
|
|
#9 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
"Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:OSWSnoMwIHA.6096@TK2MSFTNGP06.phx.gbl... > > ComputerSystem is read/write, but still, something is off: > http://msdn.microsoft.com/en-us/libr...02(VS.85).aspx > My hunch is that no matter what the docs imply, the underlying WMI infrastructure does not support this. There is a documented API function called SetDynamicTimeZoneInformation exposed by kernel32.dll: http://msdn.microsoft.com/en-us/libr...32(VS.85).aspx Unfortunately, I haven't seen a decent wrapper for this, and it appears to have a somewhat complex data structure. |
|
|
|
#10 |
|
Guest
Posts: n/a
|
Re: Update on changing TimeZone in Vista via script
greatbarrier86 wrote:
> Well, if you can't figure it out, i guess we're out of luck? > > There has to be some way...my best guess would be to do something with AutoIT. There's absolutely a way. Now whether it will be easy through PowerShell is the thing... I've not given up, just haven't had the time to revisit. I'm going to ask in a .NET Framework newsgroup. Marco |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|