Horario de verão 20008 / 20009

script para alterar horario de veão em estações de trabalho rodando windows 2k,XP e servidores com windows 2k e 2k3.
Infelizmente ao testar no vista ele altera o horário mas se reiniciar volta as configurações default.
Infelizmente não encontrei a pagina onde meu amigo Marcelo Dantas descobriu este script.

‘///////////////////////////////////////////////////////INICIO\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
‘script para alterar horario de verao no brasil
‘descoberto por Marcelo Dantas Bandeira – mdbandeira@gmail.com
‘alterado por Romeu Malacarne Avancini – rmavancini@gmail.com

Const BRASILIA_TZNAME = “E. South America Standard Time”
Const KEY_BRASILIA_TIME = “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\E. South America Standard Time”
Const KEY_TZINFO = “HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation”
Const REG_WINDOWSVERSION = “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion”

Dim strNewBrasiliaTZInfo, strNewDaylightStart, strNewStandardStart
Dim objShell, objFSO
Dim strCurrentStandardNameTZInfo
Dim intReturnValue
Dim strCurrentStandardName, strCurrentStandardNameSATime, strCurrentStandardNameSATimeMUI
Dim strRegExePath, intLastTZUpdate

On Error Resume Next

strNewBrasiliaTZInfo = “b400000000000000c4ffffff0000020000000300000000000000000000000a00000003000000000000000000”

strNewDaylightStart = “00000a00020000000000000000000000”

strNewStandardStart = “00000200030000000000000000000000”

Set objShell = CreateObject(“WScript.Shell”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objNetwork = CreateObject(“WScript.Network”)

intLastTZUpdate = 0

If LCase(objShell.Environment(“PROCESS”).Item(“OS”)) = “windows_nt” Then
    ‘Check if Timezone update was already applied. In this case, exit the script
    intLastTZUpdate = objShell.RegRead(KEY_BRASILIA_TIME & “\LastTZUpdate”)

    If intLastTZUpdate <> 2008 Then
      err.clear
      strRegExePath = getRegExePath
      If objFSO.FileExists(strRegExePath) Then
          ‘Set the registry key with the new Brasilia Timezone Information for 2008-2009
          intReturnValue = objShell.Run(strRegExePath & ” add ” & Chr(34) & KEY_BRASILIA_TIME & Chr(34) & _
                                          ” /v TZI /t REG_BINARY /d ” & _
                                        strNewBrasiliaTZInfo & ” /f”, 0, True)
          If (intReturnValue = 0) And (Err.Number = 0) Then
              ‘Check if the computer’s current time zone is (GMT -3:00) Brasilia time zone
              ‘If yes, change the current start and end daylight savings dates
              strCurrentStandardName = objShell.RegRead(KEY_TZINFO & “\StandardName”)
              strCurrentStandardNameSATime = objShell.RegRead(KEY_BRASILIA_TIME & “\Std”)
              strCurrentStandardNameSATimeMUI = objShell.RegRead(KEY_BRASILIA_TIME & “\MUI_Std”)
                                                         
              If ((Err.Number = 0) Or (Err.Number = -2147024894)) Then
                  If (LCase(strCurrentStandardName) = LCase(strCurrentStandardNameSATime)) Or _
                       (LCase(strCurrentStandardName) = LCase(strCurrentStandardNameSATimeMUI)) Then
                      ‘The current time zone is (GMT -3:00) Brasilia time zone
                      ‘Update current time zone information with the new settings
                      err.clear
                      intReturnValue = objShell.Run(strRegExePath & ” add ” & Chr(34) & KEY_TZINFO & Chr(34) & _
                                                  ” /v DaylightStart /t REG_BINARY /d ” & _
                                                  strNewDaylightStart & ” /f”, 0, True)
                                                               
                      intReturnValue = intReturnValue + objShell.Run(strRegExePath & ” add ” & Chr(34) & KEY_TZINFO & Chr(34) & _
                                                  ” /v StandardStart /t REG_BINARY /d ” & _
                                                  strNewStandardStart & ” /f”, 0, True)
                                                                                                                                       
                      If (intReturnValue = 0) And (Err.Number = 0) Then
                          ‘TimeZone information set fine
                          ‘We only need to update the current setting
                          If wscript.Version < “5.7” Then
                            objShell.Run “CONTROL.EXE TIMEDATE.CPL,,/Z ” & BRASILIA_TZNAME, 0, True
                          End If
                          lineOut “Time zone for 2007-2008 (GMT -3:00) Brasilia time zone updated successfully.” & vbCrLf & _
                                  “Current time zone for 2007-2008 updated successfully.”, 0
                          ‘Save a registry key to avoid refreshing timezone running script each startup.
                          objShell.RegWrite KEY_BRASILIA_TIME & “\LastTZUpdate”, 2007
                      Else
                          ‘Reg.exe returned an error
                          lineOut “An error occurred when updating current time zone information”, 2
                      End If
                  Else
                    lineOut “Current standard time zone is ‘” & strCurrentStandardName & “‘. No need to update it. ” & vbCrLf & _
                            “(GMT -3:00) Brasilia time zone information for 2007-2008 updated successfully.”, 0
                    ‘Save a registry key to avoid refreshing timezone running script each startup.
                    objShell.RegWrite KEY_BRASILIA_TIME & “\LastTZUpdate”, 2007
                  End If
              Else
                  ‘Error querying time zone information
                  lineOut “An error occurred querying the time zone information”, 2
              End If
             
          Else
              ‘ An error occurred when you set the Time Zone information for Brasilia Time
              lineOut “An error occurred when updating time zone information for (GMT -3:00) Brasilia”, 2
          End If
      Else
          lineOut “Could not find reg.exe in following location: ” & strRegExePath & vbCrLf & _
                  “(GMT -3:00) Brasilia time zone for 2007-2008 not updated”, 2
      End If
   End If
Else
    lineOut “Operating System not Supported. Run the script in a Windows NT-based operating system.”, 1
End If

Function getRegExePath()
    ‘Windows 2000 does not have inbox reg.exe. In this case,
    ‘we need to make sure reg.exe is present on the same folder as script is located.
      getRegExePath = objFSO.GetSpecialFolder(1) & “\reg.exe”
      If Not objFSO.FileExists(getRegExePath) Then
          getRegExePath = objFSO.GetParentFolderName(wscript.ScriptFullName) & “\reg.exe”
      End If
End Function

Sub lineOut(strLine, intType)
    Dim ScriptHost
    ScriptHost = wscript.FullName
    ScriptHost = Right(ScriptHost, Len(ScriptHost) – InStrRev(ScriptHost, “\”))
   
    If (InStr(1, wscript.FullName, “CSCRIPT.EXE”, 1) > 0) Then
        wscript.Echo strLine
    Else
        ‘Do not display anything if not running under cscript command line processor.
        ‘If you want to have a message box that contains the message,
        ‘remove the ‘ for the line under
        ‘wScript.Echo stLine
    End If
    objShell.LogEvent intType, strLine
End Sub

wscript.quit

‘///////////////////////////////////////////////////////FIM\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Anúncios

3 comments so far

  1. Tarzan on

    Puts… De 20008 até 20009? Que horário de verão demorado, sô! Só espero que a raça humana exista até lá!

    Heheh… te mandei algumas dicas..

  2. Romeu Malacarne Avancini on

    Maneiro! eu vi,
    mas pelo que entendi a dica é para usar o código dentro do html, o script é para usar via GPO.
    abração manu!
    Ps: Vou colocar a dica que vc me deu de como logar como system.

  3. Romeu Malacarne Avancini on

    eu entendi errado o que vc falou…
    vou colcar o cód. vbs usando o vim
    valeu cara


Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair / Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair / Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair / Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair / Alterar )

Conectando a %s

%d blogueiros gostam disto: