JimmyCollins Posted December 20, 2007 Share Posted December 20, 2007 Hi, I am working on a script which we run on our Vista & XP ghost images to correct the date and time before we begin running test automation. I Have half completed the script, inasmuch that the correction of the time takes place correctly. I done this by retrieving the date from an online resource and using _SetDate() to set it in the operating system. I now wish to also correct the date. - this is proving more difficult. For starters, I can't find a suitable online resource to retrieve the date from. I can't retrieve the date from the OS image because it is obviously wrong. Does anybody have any method lying around in which they do something similiar, i.e. correct the date on a Windows OS using AutoIT? Thanks, Jimmy C Link to comment Share on other sites More sharing options...
weaponx Posted December 20, 2007 Share Posted December 20, 2007 (edited) From the command line: To Synchronize an Internal Time Server with an External Time Source To open a Command Prompt window, click Start, click Run, type cmd, and then click OK. At the command prompt, type the following, where PeerList is a comma-separated list of Domain Name System (DNS) names or Internet protocol (IP) addresses of the desired time sources: w32tm /config /syncfromflags:manual /manualpeerlist:PeerList and then press ENTER. Type w32tm /config /update and then press ENTER. Note The most common use of this procedure is to synchronize the internal network's authoritative time source with precise external time source. This procedure can be run on any computer running Windows 2000, Windows XP, or Windows Server 2003. If the computer cannot reach the servers, the procedure fails and an entry is written to the Windows System event log.To Synchronize the Client Time with a Time Server To open a Command Prompt window, click Start, click Run, type cmd, and then click OK. At the command prompt, type w32tm /resync, and then press ENTER. Note This procedure only works on computers that are joined to a domain. The W32tm command-line tool is used for diagnosing problems that can occur with Windows Time Service. If you are going to use the tool on a domain controller, it is necessary to stop the service. Running the tool and Windows Time Service at the same time on a domain controller generates an error because both are attempting to use the same UDP port. When you finish using the W32tm command line tool, the service must be restarted.http://technet.microsoft.com/en-us/library/bb490605.aspx Edited December 20, 2007 by weaponx Link to comment Share on other sites More sharing options...
JimmyCollins Posted December 20, 2007 Author Share Posted December 20, 2007 From the command line: http://technet.microsoft.com/en-us/library/bb490605.aspxThis doesn't work if the time is out by day (which on images which havn't been ghosted for a while, it will).When this is run from the cmd line, an error is return "The computer did not resync because the required time change was too big." Link to comment Share on other sites More sharing options...
weaponx Posted December 20, 2007 Share Posted December 20, 2007 (edited) See here for a registry fix to ignore this error:http://www.mikebrittain.com/category/windows/HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config The default (decimal) value for both of these keys was 54,000, which is 15 hours. This means that if your local clock and the Internet clock that you are syncing to are within 15 hours of each other, the time on your PC will be updated. If they are more than 15 hours apart, forget it. The TechNet article highlighted a special case for this setting: "0xFFFFFFFF means always make time correction." So fixing this issue is just a matter of editing a couple of Registry keys. Open up the Registry Editor. (From your Start Menu, select "run" and enter "regedit".)Browse down to the "config" key to find the phase correction settings.Double-click on MaxNegPhaseCorrection to edit the value. It will read "d2f0″ in the hexidecimal value, or 54000 in the decimal value. Select "hexidecimal" and enter "ffffffff" in the field.Click "OK".Make the same change for MaxPosPhaseCorrection.Close the Registry Editor Edited December 20, 2007 by weaponx Link to comment Share on other sites More sharing options...
JimmyCollins Posted December 20, 2007 Author Share Posted December 20, 2007 See here for a registry fix to ignore this error:http://www.mikebrittain.com/category/windows/This appraoch works, but is not an option for me as it requires a restart, and the script is run in the middle of another test automation script.Thus, the machine would restart continuosly.Does anyone know if there is any way to refresh/reload the registry without restarting? Link to comment Share on other sites More sharing options...
weaponx Posted December 20, 2007 Share Posted December 20, 2007 Did you try EnvUpdate()? Link to comment Share on other sites More sharing options...
JimmyCollins Posted December 20, 2007 Author Share Posted December 20, 2007 Did you try EnvUpdate()?This works on V32 but not on XP or V64. If I do it manually it works on all. Do you know if there are issues with EnvUpdate() on XP of V64? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now