当前位置:网站首页>Regularly modify the system time of the computer

Regularly modify the system time of the computer

2022-07-07 09:10:00 Stick to this persistence

One 、 Preface

When developing tests , It is often necessary to change the server time according to the business scenario ,Java The current server time obtained by the development background is the system time of the computer , Manual change is too troublesome , So I wrote a timed script , Double click to execute .

Two 、 Code implementation

newly build changeTime.bat file , The contents are as follows :

@date 2020-01-01
@time 9:00

@echo off
:begin
echo wscript.echo DateAdd("d",1,date) >$.vbs
for /f "delims=" %%a in ('cscript /nologo $.vbs') do date %%a
del $.vbs
@time 9:00
ping -n 60 127.1>nul
goto begin

explain : from 2020-01-02 9:00 Start , Change server time , Every time 1 minute (60 second )(ping -n 60 127.1) Automatically +1 God .

3、 ... and 、 test

double-click changeTime.bat, See the effect .

原网站

版权声明
本文为[Stick to this persistence]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130628319348.html