Bruno_Leveque
(Fresh Scripter)
2005-03-11 01:58 PM
How to change windows date ?

Hi everybody,

I'm seeking a simple method to change the date of Windows (ex : 2005/03/11 -> 2005/03/13). I didn't find any suitable function in Kixtart handbook, an idea?

Thank you in advance


Les
(KiX Master)
2005-03-11 02:19 PM
Re: How to change windows date ?

KiX does not have an intrinsic command or function to change the date. For that, you would have to either drop to DOS and use the W32Tm or TIME command, or use COM or WMI. Perhaps you should give some background on why you would want to change the date in a script. If you are running Active Directory, you can expect major problems if you muck with the date/time.

You should have all the computers sync time with the W32Time/W32Tm service.


Bruno_Leveque
(Fresh Scripter)
2005-03-11 02:30 PM
Re: How to change windows date ?

I already tested the DOS commande "date" but I need a command with which I would be able to pass an argument (and not have a blocking prompt) :

date [new_date]

The goal is simply to test one of my kixtart scripts from which result differs according to the system date.


Les
(KiX Master)
2005-03-11 02:39 PM
Re: How to change windows date ?

There are lots of ways to show results. You could log to a file or the registry, or return ERRORLEVEL with the EXIT command.

ShawnAdministrator
(KiX Supporter)
2005-03-11 02:44 PM
Re: How to change windows date ?

I just tried this on WinXP and it did not block ...

C:\>date 2005-03-12
C:\>

Of course, it helps to be a local admin when your setting the clock too.


Kdyer
(KiX Supporter)
2005-03-11 02:48 PM
Re: How to change windows date ?

another way you could do this is to -
Code:

C:\Documents and Settings\Kent>echo 3/13/2005 | date
The current date is: Fri 03/11/2005
Enter the new date: (mm-dd-yy) 3/13/2005



This you would have to shell out for from KiX. The caveat to this would be if you have NNTP setup on the domain and you point your clients to it. Once they talk to the server that goes to the atomic clock, the date/time will change back if using W32time/W32TM as Les suggested.

Thanks,

Kent


Bruno_Leveque
(Fresh Scripter)
2005-03-11 02:50 PM
Re: How to change windows date ?

Quote:

I just tried this on WinXP and it did not block ...

C:\>date 2005-03-12
C:\>

Of course, it helps to be a local admin when your setting the clock too.




Ok this is what I wanted

Thanks a lot !


Sealeopard
(KiX Master)
2005-03-11 07:58 PM
Re: How to change windows date ?

Use the Windows Time Service to keep time synchronizes as is required for AD or use SETTIME under Windows 9x.

Kdyer
(KiX Supporter)
2005-03-11 11:15 PM
Re: How to change windows date ?

W32Time..
Windows NT it is an add-in, W2k+ is in-build.

Kent


Glenn BarnasAdministrator
(KiX Supporter)
2005-03-12 06:27 AM
Re: How to change windows date ?

Just a small technical clarification.

AD requires time synchronization AND a service named "W32Time" to be present. It does not require "W32Time" to actually function.

We run a SNTP server everywhere, and have W32Time disabled, since the SNTP service provides higher accuracy for our application environment. Oddly, when joining a server to an AD, the system craps out if a service called W32Time isn't present or can't be started. I say "a service called W32Time" because that service isn't required to do anything if you have good time sync! I've replaced the W32Time defined binary with CMD.EXE on a test server and was able to join the AD, when it fails if the W32Time service is removed entirely.

Maybe irrelevent, but maybe interesting trivia for some, too.

Glenn


Sealeopard
(KiX Master)
2005-03-12 02:01 PM
Re: How to change windows date ?

Yes, interesting trivia. What I should have said is that AD requires time to be synchronized to within 5 seconds by default. I was not to imply that the Windows Time Service must be used to achieve this synchronization, though. My bad.

Les
(KiX Master)
2005-03-12 02:21 PM
Re: How to change windows date ?

Yes, it is all interesting trivia, but trivia is all it is since this thread is not about keeping time syncronized but rather about using the time as a visual indicator of script action.

I thinks doing so is a very VERY V E R Y bad idea as there are lots of better ways to do it.