标题: 删除指定日期文件的批处理在我电脑可以运行,换公司电脑为何失败? [打印本页]
作者: 小黄桃 时间: 2011-10-30 17:33 标题: 删除指定日期文件的批处理在我电脑可以运行,换公司电脑为何失败?
- @echo off
- ::get the date
- >del_7Days_data.vbs echo wscript.echo dateadd("d",-7,date)
- for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo Del_7Days_data.vbs') do (
- set y=%%i
- set m=%%j
- set d=%%k
- )
- if %m% LSS 10 set m=0%m%
- if %d% LSS 10 set d=0%d%
- set ht=%y%-%m%-%d%
- echo Delete The eclipse TCPlan before %ht%
- pause
- ::Judge the file
- for /f "skip=4 delims=" %%i in ('dir/tc F:\sfssfd\hwll_*.pln') do call :w "%%i"
- del_7Days_data.vbs
- goto :eof
- :w
- for /f "tokens=4 delims= " %%a in (%1) do set str=%%a
- set var=%1
- set num=%var:~1,10%
- if %num% lss %ht% del /q F:\sfssfd\%str%
复制代码
把5、6、7行的语句注释掉就能运行到 pause那里,就是双击这个bat文件之后没反应,出现这个CMD窗口了,然后瞬间就关闭了,结果是啥都没运行,这个pause也没体现出来。
公司电脑没有任何第三方软件,所以没有木马和360的软件,就一个系统,而且此电脑无法上网,肯定排除木马等因素。请给予帮助,谢谢!!
作者: weichenxiehou 时间: 2011-10-30 17:46
本帖最后由 weichenxiehou 于 2011-10-30 17:50 编辑
回复 1# 小黄桃
猜测是你家里的电脑和公司的电脑显示的时间格式不一样,也就是时间中间并不是以"-"作为分隔符。试试:- @echo off
- ::get the date
- >del_7Days_data.vbs echo wscript.echo dateadd("d",-7,date)
- for /f "tokens=1,2,3* delims=/" %%i in ('cscript /nologo Del_7Days_data.vbs') do (
- set y=%%i
- set m=%%j
- set d=%%k
- )
- if %m% LSS 10 set m=0%m%
- if %d% LSS 10 set d=0%d%
- set ht=%y%/%m%/%d%
- echo Delete The eclipse TCPlan before %ht%
- pause
- ::Judge the file
- for /f "skip=4 delims=" %%i in ('dir/tc F:\sfssfd\hwll_*.pln') do call :w "%%i"
- del_7Days_data.vbs
- goto :eof
- :w
- for /f "tokens=4 delims= " %%a in (%1) do set str=%%a
- set var=%1
- set num=%var:~1,10%
- if %num% lss %ht% del /q F:\sfssfd\%str%
复制代码
作者: 920168 时间: 2011-10-31 14:01
- @echo off
- ::get the date
- >del_7Days_data.vbs echo wscript.echo dateadd("d",-7,date)
- for /f "tokens=1,2,3* delims==-/. " %%i in ('cscript /nologo Del_7Days_data.vbs') do (
- set y=%%i
- set m=%%j
- set d=%%k
- )
- if %m% LSS 10 set m=0%m%
- if %d% LSS 10 set d=0%d%
- set ht=%y%/%m%/%d%
- echo Delete The eclipse TCPlan before %ht%
- pause
- ::Judge the file
- for /f "skip=4 delims=" %%i in ('dir/tc F:\sfssfd\hwll_*.pln') do call :w "%%i"
- del_7Days_data.vbs
- goto :eof
- :w
- for /f "tokens=4 delims= " %%a in (%1) do set str=%%a
- set var=%1
- set num=%var:~1,10%
- if %num% lss %ht% del /q F:\sfssfd\%str%
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |