本帖最后由 pcl_test 于 2019-10-27 00:31 编辑
- @echo off& setlocal enabledelayedexpansion
- for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value') do set "d=%%a"
- set "d=%d:~,4%-%d:~4,2%-%d:~6,2%"
- ::设置有效天数
- set n=7
- for /f "tokens=3" %%a in ('reg query HKCU /v WriteDate 2^>nul^|findstr "[0-9]"') do set "t=%%a"
- >"%tmp%\v.v" echo;d=DateAdd("d", Clng(WSH.Arguments(0)), WSH.Arguments(1)):WSH.echo right(year(d),4) ^& right("0" ^& month(d),2) ^& right("0" ^& day(d),2)
-
- if defined t (
- for /f "delims=" %%a in ('cscript -nologo -e:vbscript "%tmp%\v.v" %n% %t%') do set "nd=%%a"
- echo;首次运行日期%t%
- echo;有效期%n%天(即到!nd:~,4!-!nd:~4,2!-!nd:~6,2!)
- echo;当前日期%d%
- echo;
- set "d=%d:-=%"
- if !d! lss !nd! (
- echo;状态:未过期
- ) else if !d! equ !nd! (
- echo;状态:已到期
- ) else (
- echo;状态:已过期
- set /p c=^>^>是否重置首次运行日期[Y/N]:
- if /i "!c!" equ "y" (reg delete HKCU /v WriteDate /f))
- ) else (
- reg add HKCU /v WriteDate /t REG_SZ /d %d% /f
- echo;首次运行日期%d%,已记录
- )
- >nul ping /n 3 0
- pause
- exit
复制代码
|