非常感谢楼上各位大侠的帮助. 代码调试通过了, 最后从格式上做了些美化. 执行的结果会写入当前路径 以当前日期为文件名的日志, 内容如下, 并附上代码, 谢谢大家.
\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for Administrator On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (2).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (3).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (4).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (5).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy (6).ost 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy (2) - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy (2).pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy - Copy - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy - Copy.pst 0
Deleting C:\Users\Administrator\AppData\Local\Microsoft\Outlook\test - Copy.pst 0
删除了12个文件,一共为0KB
============================Below Files can't be Removed============================
\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for All Users On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for Default On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for Default User On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\\\\\\\\\\\\\\\\\\\\\2012/02/17 周五10:43:39.41, Deleting Files for admin On admin-MOBL, IP: 192.168.10.1\\\\\\\\\\\\\\\\\\\\\\\\\- @echo off
-
- ipconfig
- @echo -
- for /f "tokens=2 delims=:" %%i in ('ipconfig^|findstr "Address"') do set ip=%%i
- cls
- REM @echo ==================[你的IP地址是:%ip%]===============
-
-
- REM ====================================================
- @ECHO OFF
- :: The Program only works on Windows English Version
- :: For Example
- :: The current date is: 05/27/2009 Wed
- :: Enter the new date: (mm-dd-yy)
-
- ECHO.|DATE >temp1
- FOR /F "eol=T tokens=5 delims=() " %%i in (temp1) do set date_format=%%i
-
- FOR /F "eol=E tokens=5,6,7,8 delims=/- " %%a in (temp1) do (
- IF /I %date_format% EQU mm-dd-yy ( set month=%%a
- set day=%%b
- set year=%%c
- set week=%%d )
- IF /I %date_format% EQU dd-mm-yy ( set day=%%a
- set month=%%b
- set year=%%c
- set week=%%d )
- IF /I %date_format% EQU yy-mm-dd ( set year=%%a
- set month=%%b
- set day=%%c
- set week=%%d ) )
-
-
- SET current_date=%year%-%month%-%day%
-
- IF EXIST temp1 DEL /Q temp1
-
-
- REM ECHO Current date = %current_date%
- REM ====================================================
-
-
- set RootFolder=C:\Users
- set SubFolder=AppData\Local\Microsoft\Outlook
-
- for /f "delims=" %%i in ('dir /ad /b C:\users') do (
- REM echo %RootFolder%\%%i\%SubFolder%\*.ost
- REM echo %current_date%.log
-
- REM ====================================
- setlocal enabledelayedexpansion
- set n=&set ds=0
-
- echo \\\\\\\\\\\\\\\\\\\\\\\\\%date%%time%, Deleting Files for %%i On %computername%, IP:%ip%\\\\\\\\\\\\\\\\\\\\\\\\\>>%current_date%.log
- echo. >>%current_date%.log
- if exist "%RootFolder%\%%i\%SubFolder%\*.ost" (
-
- for /f "delims=" %%j in ('dir /b/s %RootFolder%\%%i\%SubFolder%\*.ost') do (set /a n=!n!+1
- echo Deleting %%j %%~zj>>%current_date%.log
- del /q/f "%%j"
- set /a ds=!ds!+%%~zj
- )
-
- echo.>>%current_date%.log
-
- for /f "delims=" %%j in ('dir /b/s %RootFolder%\%%i\%SubFolder%\*.pst') do (set /a n=!n!+1
- echo Deleting %%j %%~zj>>%current_date%.log
- del /q/f "%%j"
- set /a ds=!ds!+%%~zj
- )
-
- echo.>>%current_date%.log
- echo 删除了!n!个文件,一共为!ds!KB>>%current_date%.log
-
- echo ============================Below Files can't be Removed============================>>%current_date%.log
- dir /d /b %RootFolder%\%%i\%SubFolder%\*.ost >>%current_date%.log
- dir /d /b %RootFolder%\%%i\%SubFolder%\*.pst >>%current_date%.log
- echo. >>%current_date%.log
- echo. >>%current_date%.log
- )
- REM End "If Exist on line58"
-
- )
- REM End "For on line48"
复制代码
|