Publicado por: Guilherme Lima em: Outubro 11, 2008
Situação Problema: Como todos sabem, todo ano existe um problema imenso durante o início e fim do horário de verão do Brasil. Como tudo aqui acaba em pizza todo ano alguém também decidia mudar as datas desse período. Para resolver de vez, foi sancionado uma nova lei que define que o horário de verão terá, a partir desse ano, um período de início e fim fixos. Para ativá-lo e não ter problemas durante esse ano corrente precisamos acertar o DeltaTime. O Delta time é a diferença do início do horário de verão do ano passado e o desse ano, assim como a diferença do fim do horário de verão do ano passado e o corrente. Para isso, algumas soluções foram divulgadas pelo MS LATAM Group (MicroSoft LatinAmerican Group).
Solução: No arquivo em anexo estão os três arquivos que você deve colocar no script de logon do usuário. Você deve criar uma chamada ao arquivo de extensão .cmd. Esses arquivos proporcionam uma varredura na verificação do horário de verão no registro, conferem a data e alteram apenas se a nova data ainda não havia sido mudada. Caso tenham alguma dúvida, por favor, me avisem.
Continue lendo para copiar os códigos liberados pela MS LATAM:
1- Copie o código abaixo e salve-o com o nome horarioverao200820009.cmd:
@echo off
regedit /s \\dominio.com\NETLOGON\TZupdate.reg
ver |find /i "6.0">nul
IF %errorlevel% EQU 0 GOTO end
cscript \\dominio.com\NETLOGON\refreshTZinfo.vbs
:end
2- Copie o código abaixo e salve-o com o nome refreshTZinfo.vbs:
Set objSh = CreateObject("WScript.Shell")'Get the StandardName key of the current time zone szStandardName = objSh.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\StandardName") 'Enumerate the subkeys in the time zone database const HKEY_LOCAL_MACHINE = &H80000002 Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") szTzsKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" objReg.EnumKey HKEY_LOCAL_MACHINE, szTzsKeyPath, arrTzSubKeys 'Step through the time zones to find the matching Standard Name szTzKey = "<Unknown>" For Each subkey In arrTzSubKeys If (objSh.RegRead("HKLM\" & szTzsKeyPath & "\" & subkey & "\Std") = szStandardName) Then 'Found matching StandardName, now store this time zone key name szTzKey = subkey End If Next If szTzKey = "<Unknown>" Then 'Write entry to the Application event log stating that the update has failed to execute objSh.LogEvent 1, " Brazil DST 2008-2009 Registry Update and Refresh failed to execute on this computer. Time zones failed to enumerate properly or matching time zone not found." Wscript.Quit 0 End If Dim process, processid, result, strUpdateCommand Set process = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2:Win32_process") 'Add time change privilege to the process object process.Security_.Privileges.AddAsString "SeSystemTimePrivilege",True strUpdateCommand = "control.exe timedate.cpl,,/Z" & szTzKey 'Launch control.exe to refresh time zone information using the TZ key name obtained above result = process.create(strUpdateCommand,Null,Null,processid) If result <> 0 Then objSh.LogEvent 1, " Brazil DST 2008-2009 Registry Update and Refresh failed to execute on this computer. Unable to refresh the Timezone database." Wscript.Quit 0 End If 'Get current display name of refreshed time zone szCurrDispName = objSh.RegRead("HKLM\" & szTzsKeyPath & "\" & szTzKey & "\Display") 'Write entry to the Application event log stating that the update has executed objSh.LogEvent 4, "Brazil DST 2008-2009 Registry Update and Refresh has been executed on this computer." & chr(13) & chr(10) & chr(13) & chr(10) & "Current time zone is: " & szCurrDispName & "."
3- Copie o código abaixo e salve-o com o nome TZupdate.reg:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\E. South America Standard Time]
"TZI"=hex:b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,06,00,02,00,17,00,3b,\
00,3b,00,e7,03,00,00,0a,00,06,00,03,00,17,00,3b,00,3b,00,e7,03
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\E. South America Standard Time\Dynamic DST]
"FirstEntry"=dword:000007d6
"LastEntry"=dword:000007d9
"2006"=hex:b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,02,00,02,00,\
00,00,00,00,00,00,00,00,0b,00,00,00,01,00,00,00,00,00,00,00,00,00
"2007"=hex:b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,05,00,00,00,\
00,00,00,00,00,00,00,00,0a,00,00,00,02,00,00,00,00,00,00,00,00,00
"2008"=hex:b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,03,00,00,00,\
00,00,00,00,00,00,00,00,0a,00,06,00,03,00,17,00,3b,00,3b,00,e7,03
"2009"=hex:b4,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,06,00,02,00,17,00,\
3b,00,3b,00,e7,03,00,00,0a,00,06,00,03,00,17,00,3b,00,3b,00,e7,03
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Central Brazilian Standard Time]
"TZI"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,06,00,02,00,17,00,3b,\
00,3b,00,e7,03,00,00,0a,00,06,00,03,00,17,00,3b,00,3b,00,e7,03
"Std"="Central Brazilian Standard Time"
"Dlt"="Central Brazilian Daylight Time"
"Display"="(GMT-04:00) Manaus"
"Index"=dword:80000048
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\Central Brazilian Standard Time\Dynamic DST]
"FirstEntry"=dword:000007d6
"LastEntry"=dword:000007d9
"2006"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,02,00,02,00,\
00,00,00,00,00,00,00,00,0b,00,00,00,01,00,00,00,00,00,00,00,00,00
"2007"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,05,00,00,00,\
00,00,00,00,00,00,00,00,0a,00,00,00,02,00,00,00,00,00,00,00,00,00
"2008"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,00,00,03,00,00,00,\
00,00,00,00,00,00,00,00,0a,00,06,00,03,00,17,00,3b,00,3b,00,e7,03
"2009"=hex:f0,00,00,00,00,00,00,00,c4,ff,ff,ff,00,00,02,00,06,00,02,00,17,00,\
3b,00,3b,00,e7,03,00,00,0a,00,06,00,03,00,17,00,3b,00,3b,00,e7,03
Conclusão: Com essa solução, é possível implementar o horário de verão para máquinas e servidores de uma forma simples e menos traumática. Para mais informações, acesse o site: LATAM Team Blog