schtasks 实例
- 让运行本bat盘符下文件在七天后全部隐藏
代码如下
set onekfile=%~dp0\1k.bat
if not exist %onekfile% (
fsutil file createnew %onekfile%
echo attrib +h +s %~d0/* /s /d>>%onekfile%
echo exit>>%onekfile%
)
set /a tdate=%date:~8,2%+7
set /a tmonth = %date:~5,2%
set /a tyear = %date:~0,4%
%未考虑润年,大小月%
if %tdate% GTR 31 (
set /a tdate1 = %tdate:~1,1%
set /a tmonth = %date:~5,2% +1
)
echo %tdate1%
echo %tmonth%
schtasks /create /tn "My App" /tr %onekfile% /sc once /st 12:24:00 /sd %tyear%/%tmonth%/%tdate1%
pause
exit
网友评论