windows任务计划CMD方式的实现

运用好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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值