TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Windows Powershell

Notices

Reply
 
Thread Tools Display Modes
Old 27-05-2008, 07:54 PM   #1
greatbarrier86
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
  Reply With Quote
Old 27-05-2008, 08:58 PM   #2
Marco Shaw [MVP]
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
  Reply With Quote
Old 27-05-2008, 09:56 PM   #3
greatbarrier86
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
>

  Reply With Quote
Old 27-05-2008, 11:57 PM   #4
Marco Shaw [MVP]
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
  Reply With Quote
Old 28-05-2008, 01:57 AM   #5
greatbarrier86
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
>

  Reply With Quote
Old 28-05-2008, 09:56 AM   #6
Marco Shaw [MVP]
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
  Reply With Quote
Old 28-05-2008, 08:54 PM   #7
greatbarrier86
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
>

  Reply With Quote
Old 28-05-2008, 08:54 PM   #8
Marco Shaw [MVP]
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
  Reply With Quote
Old 29-05-2008, 12:57 AM   #9
Alex K. Angelopoulos
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.

  Reply With Quote
Old 29-05-2008, 06:51 PM   #10
Marco Shaw [MVP]
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
  Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 02:55 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional