How to Set System Time
Keywords: clock system time
Question:
Is there a WinBatch function that will let me set the system clock, or do I have to use the DOS command Time? It seems all the time functions are for getting the time, adding to it, displaying it in a different format etc., but none for actually resetting the system clock.Same question for system date.
Answer:
In the current versions of WinBatch, we have an IntControl(58...) to set the system time.If you are running an older version, here is a method that works for the date. Should also work for time by substituting the correct info.
IntControl(58, p1, 0, 0, 0) Set system time. P1 = new system time, in YmdHms format. This IntControl changes the time of the computer's system clock. Returns @TRUE on success, @FALSE on failure.
- Create "c:\date.pif", which is a shortcut to DOS. The shortcut should have "c:\date.bat" listed as the program, "c:\" listed as the working directory. Set the shortcut to run in a minimized window which closes on exit.
- Create "c:\date.bat", which contains the following line:
date %1- Create "date.wbt", which contains the following line:
runwait("c:\Date.pif","MM/DD/YY")The .wbt file calls the pif, which opens the minimized DOS window and passes the date parameter to the batch file. The batch changes the system date, then all files close in the reverse order that they were opened.
Article ID: W13874Filename: How to Set System Time.txt