WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Time - Timer and Date Functions
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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.

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.
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.
  1. 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.

  2. Create "c:\date.bat", which contains the following line:
    date %1 
    
  3. 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:   W13874
Filename:   How to Set System Time.txt
File Created: 2001:01:09:12:08:46
Last Updated: 2001:01:09:12:08:46