3
I made a bat file that changes the windows date.
However, I also need another bat file, so when executed, it recovers the updated date.
How to proceed?
3
I made a bat file that changes the windows date.
However, I also need another bat file, so when executed, it recovers the updated date.
How to proceed?
2
- Saving the date is possible, but the best thing is synchronize to
data/hora
via internet, where it is possible to get updated more practical and accurate, for this, use thiscódigo
:
@echo off & color 0a && setlocal enableextensions enabledelayedexpansion
tzutil /s "E. South America Standard Time"
w32tm /query /status 2>nul >nul
if not !errorlevel! == 0 (
w32tm /register && net start w32time
w32tm /config /manualpeerlist:a.ntp.br /syncfromflags:manual /reliable:yes /update
w32tm /resync /force /nowait && net stop w32time
w32tm /unregister
) else (
w32tm /config /manualpeerlist:a.ntp.br /syncfromflags:manual /reliable:yes /update
w32tm /resync /force /nowait && net stop w32time
)
Very good the solution, I think I would only change the fact to stop and deregister the service always, to do this only when the solution itself starts the service (If). And also, in the documentation, the option /resync
does not have a subopção /force
.
@Pedro Gaspar, I am not a fan of maintaining services and/or records when they are not in use, or their use is occasional. o **/force**
, exists, add any add-on that is not supported in w32tm , and will display the message from error:" The following arguments were not expected:"
Keep service: but if he was already being executed, it would not be better to "keep as found"? / /force: Truth: Powertip: Force Time Resync with Powershell.
@Pedro Gaspar, Boa!! , tendi, now keep as found... Liked, thanks!
Browser other questions tagged batch
You are not signed in. Login or sign up in order to post.
What you’ve tried so far Clara?
– gmsantos
What I thought at first was to save the date in a text file before it was changed, but I couldn’t save it. And I do not know if there is only this solution, I thought I had some variable windows environment that already bring updated the date in real time.
– Clara Campos