Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
5 years ago

efficient way of changing system date

Hi,

I musn't be the only one who need to change its system datetime while executing tests...

I tried two ways, this one :

net time /set /yes

and this one :

w32tm /resync

with the command line, but both don't work 100% of the time.

 

Does anyone has any workaround ?

 

Thank you

 

  • BenoitB's avatar
    BenoitB
    Community Hero

    Stop the W32Time service before changing date/time because unless that the time will be resync automatically after short time.

     

    You can stop it using cmd in administrator mode with NET STOP W32Time /YES

    To change machine date/time use DATE and TIME in cmd

    If not working with NET STOP you can use SC object.

      • m_essaid's avatar
        m_essaid
        Valued Contributor

        Hi all,

         

        Seems to be the cleanest way to resolve my problem ! Thank you !

        I'm on windows 10.

        I already have a clue for preventing the PC resetting the date. For this key :

        HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters

        I set "Type" to "NoSync".

        Thus the domain controller leave my machine alone.