您的位置:首页 > 其它

windows任务计划CMD方式的实现

2017-12-07 10:37 495 查看
运用好windows CMD可以实现linux shell功能,不需要辅助其它语言。

实现方法:

编辑copyFileVBS.vbs,然后通过系统任务计划实现, 类似crontab命令设置周期性执行文件:

copyFileVBS.vbs:

'//格式化月份为2位 & 

function formatmonth(m)
if m<9 then

  formatmonth="0" & m
else

  formatmonth=m 
End if

end function

'//文件名 一位月份

function formatflname(n)

' if m=1 then

' formatflname="d"

' Else
if n=10 then

  formatflname="a"
Elseif n=11 then

  formatflname="b"
ELSEif n=12 then

  formatflname="c"
Else

  formatflname=n 
End if

end function

'//格式化目录

function formatDir(d)
if len(d)=1 then

  formatDir="00" & d
elseif len(d)=2 then

  formatDir="0" & d
end if

end function

yy=Right(year(now()),2)

mm=Right("0" & month(now()),2)

dd=Right("0" & day(now()),2)

yestday=Right("0" & day(now()-1),2)

Dim oShell,fso

Set oShell = WScript.CreateObject("WScript.Shell")

Set fso = CreateObject("Scripting.FileSystemObject")

Set f1 = fso.CreateTextFile("c:\copy1file"&yy&mm&dd&"tmp.bat",true)

f1.write "copy /y t:\tasv\" & yy & mm & "\FOLIO" & dd & ".DBF T:\TASV\Currently\" & yy & mm & "\" 

f1.close

REM 传递参数定义

REM %1 目录回路

REM %2 年份

REM %3 一位月份

REM %4 2位日期

REM %5 二位月份

'    MsgBox yy & mm & dd
oShell.Run "D:\netuse\netuser1diskD.bat"
oShell.Run "c:\copy1file"&yy&mm&dd&"tmp.bat"

' oShell.Run "copy /y T:\TASV" & yy & mm & "\FOLIO" & dd & ".DBF T:\TASV\Currently\" & yy & mm & "\"

' fso.copyfile "T:\TASV" & yy & mm & "\FOLIO" & dd & ".DBF","T:\TASV\Currently\" & yy & mm,true
MsgBox "copy /y t:\tasv\" & yy & mm & "\FOLIO" & dd & ".DBF T:\TASV\Currently\" & yy & mm & "\"

'copy t:\tasv\1510\FOLIO16.DBF T:\TASV\Currently\1510

set oshell = nothing

set fso = Nothing

WScript.quit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐