具体要求:
如果今天是星期四,则执行xcopy xxxx xxxx,接着再按顺序执行后面的命令,如果不是星期四则跳过xcopy xxxx xxxx命令,按顺序执行后面的命令。
为什么运行到空行之后就不能再运行后面的命令了,也就是运行到“start %temp%\aaa.bat”之后,后面的命令就不能被执行了,另外:在运行这个P的时候会有一个黑的P窗口出现,如何让他不出现。求大大们帮忙,谢谢- ::每星期四备份一次收藏夹
- echo if "%%date:~-1%%" == "四" call:thursday>>%temp%\aaa.bat
- echo goto :eof>>%temp%\aaa.bat
- echo :thursday>>%temp%\aaa.bat
- echo xcopy /e /h /i /k /y D:\Favorites\* E:\Favorites>>%temp%\aaa.bat
- echo goto :eof>>%temp%\aaa.bat
- start %temp%\aaa.bat
-
- taskkill /f /im IExplore.exe
- del /f /s /q "%userprofile%\Local Settings\History\*"
- attrib -s -h "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5\*">nul 2>nul
- del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5\*">nul 2>nul
- rd /s /q "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5">nul 2>nul
复制代码 以下是我自己的解决方法(其实大同小异),留给和我一样不懂批处理的人的一个参考,高手莫笑- @echo off
- ::每周四备份IE收藏夹到"E:\Favorites"下
- Setlocal enabledelayedexpansion
- for /f "skip=2 delims=: tokens=1,*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Favorites') do (
- set str=%%i
- set var=%%j
- set "var=!var:"=!"
- if not "!var:~-1!"=="=" echo xcopy /e /h /i /k /y !str:~-1!:!var!\* e:\Favorites\>%temp%\aaa.bat
- )
- if "%date:~-1%" == "四" call %temp%\aaa.bat
-
- taskkill /f /im IExplore.exe
- del /f /s /q "%userprofile%\Local Settings\History\*"
- attrib -s -h "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5\*">nul 2>nul
- del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5\*">nul 2>nul
- rd /s /q "%userprofile%\Local Settings\Temporary Internet Files\Content.IE5">nul 2>nul
复制代码
|