Changebacktz2011.vbs

Páginas: 2 (305 palabras) Publicado: 9 de mayo de 2011
Modificar zona horaria en active directory

On Error Resume Next

strNewTimeZone = "Pacific SA Standard Time"

Set objSh = CreateObject("WScript.Shell")

'Get the StandardName key of thecurrent time zone

szStandardName = objSh.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\StandardName")

'Enumerate the subkeys in the time zone database

ConstHKEY_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

szCurrentTzKey = ""

For Each subkey In arrTzSubKeysstrTimeZoneStandarName = ""

strTimeZoneStandarName = objSh.RegRead("HKLM" & szTzsKeyPath & "" & subkey & "\Std")

If (strTimeZoneStandarName = szStandardName) Then

'Found matching StandardName, now storethis time zone key name

szCurrentTzKey = subkey

End If

Next

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"& strNewTimeZone

'Launch control.exe to change time zone using the TZ key name stored in strNewTimeZone

result = process.Create(strUpdateCommand, Null, Null, processid)

If result 0 ThenobjSh.LogEvent 1, "Process to change machine time zone failed to execute on this computer. Unable to change machine time zone."

wScript.Quit 0

End If

'Get the display name from previoustime zone and compare with the new time zone

szPrevDispName = objSh.RegRead("HKLM" & szTzsKeyPath & "" & szCurrentTzKey & "\Display")

szNewDispName = objSh.RegRead("HKLM" & szTzsKeyPath & "" &...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Todo de vbs
  • Codigo vbs suma for
  • Diccionario de claves .vbs

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS