最近用到一款软件,但是其找到的版本试用期过了,更改系统时间后可用,但是每次都要更改很麻烦。查询资料后写了段脚本。
@echo off
date 2020-8-25
::cd到当前目录
cd /d %~dp0
start ABC.exe
echo 等待启动软件中
ping -n 5 127.0.0.1
::更新到网络时间
net time \\xxx_server
net stop w32time
net start w32time
w32tm /resync
date命令修改时间
ping命令是为了等待启动该软件
net time命令 同步网络时间,xxx_server可以是域内的某台服务器或者internet上的某台服务器,如:
- 阿里云NTP服务:server ntp1.aliyun.com
- 腾讯云:server time1.cloud.tencent.com
有时候需要重启w32time服务才能更新网络时间
最后,启动的时候记得给管理员权限
参考:https://www.cnblogs.com/ryansunyu/p/7845511.html