保存bat文件,asni编码- @echo off & cd /d "%~dp0"
- REM 管理员权限
- %1 start "" mshta vbscript:createobject("shell.application").shellexecute("""%~0""","REM",,"runas",1)(window.close)&exit
- REM 当前数据库文件
- set "curDB=C:\Program Files\Kingdee\K3Cloud\DeskClient\Retail_Client\mtaposinfo.db"
- REM 数据库备份文件夹
- set "backDir=C:\Program Files\Kingdee\K3Cloud\DeskClient\Retail_Client\DBBackup"
- REM 获取前一天日期
- set "lastDay="
- set "code=mshta "javascript:var d=new Date();d.setDate(d.getDate()-1);new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(''+d.getFullYear()+('00'+(d.getMonth()+1)).replace(/^.*(.{2})$/,'$1')+('00'+d.getDate()).replace(/^.*(.{2})$/,'$1'));window.close();""
- for /f "delims=" %%i in ('%code%') do set "lastDay=%%i"
- set "recoverDB=%backDir%\mtaposinfo_%lastDay%_start_.db"
- echo 当前日期: %DATE%
- echo 前一天: %lastDay%
- echo 目标文件: %curDB%
- echo 恢复文件: %recoverDB%
- if exist "%recoverDB%" (
- copy /y "%recoverDB%" "%curDB%"
- ) else (
- echo 未找到: %recoverDB%
- )
- pause&exit
复制代码
|