本帖最后由 went 于 2020-4-3 11:29 编辑
写入日期到日志文件:- echo.%date:~0,10%,%time:~0,8%>>"%~dp0\logDT.txt"
复制代码 更新日期:- @echo off
- setlocal enabledelayedexpansion
- %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","REM",,"runas",1)(window.close)&exit
- set "logDT=%date:~0,10%,%time:~0,8%"
- for /f "usebackq delims=" %%i in ("%~dp0\logDT.txt") do if "!logDT!" lss "%%i" set "logDT=%%i"
- if "%date:~0,10%,%time:~0,8%" lss "%logDT%" (
- echo update date time : %logDT%
- date %logDT:~0,10%
- time %logDT:~11,8%
- )
- pause&exit
复制代码 开机自动修改要把bat放到C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp路径 |