Windows备份脚本

Windows备份脚本

  • 双击直接运行

双击直接运行

@echo off
REM # 获取管理员权限
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"

REM ###########################################################
REM # 日志自动备份批处理脚本
REM ###########################################################

REM 取当前系统时间,可能因操作系统不同而取值不一样
set CURDATE=%date:~0,4%%date:~5,2%%date:~8,2%
set CURTIME=%time:~0,2%

REM 小时数如果小于10,则在前面补0
if "%CURTIME%"==" 0" set CURTIME=00
if "%CURTIME%"==" 1" set CURTIME=01
if "%CURTIME%"==" 2" set CURTIME=02
if "%CURTIME%"==" 3" set CURTIME=03
if "%CURTIME%"==" 4" set CURTIME=04
if "%CURTIME%"==" 5" set CURTIME=05
if "%CURTIME%"==" 6" set CURTIME=06
if "%CURTIME%"==" 7" set CURTIME=07
if "%CURTIME%"==" 8" set CURTIME=08
if "%CURTIME%"==" 9" set CURTIME=09

set CURTIME=%CURTIME%%time:~3,2%%time:~6,2%

REM WINDWOS日志
REM WIN_EVT日志目录
set winevt_log_dir=C:\Windows\System32\winevt\Logs\
REM WIN_EVT日志备份目录
set winevt_log_backdir=D:\backup\log\winevt
REM 若目标路径不存在则创建
if not exist "%winevt_log_backdir%\winevt_log_%CURDATE%" mkdir %winevt_log_backdir%\winevt_log_%CURDATE%
REM 备份WIN_EVT日志
xcopy %winevt_log_dir% %winevt_log_backdir%\winevt_log_%CURDATE% /s/y/c/k/e

exit

你可能感兴趣的:(网络安全,等保测评,IT,windows,java)