本帖最后由 weichenxiehou 于 2013-8-8 21:38 编辑
回复 5# tz_being
保存为.vbs:- option explicit
- dim fso,datefile,objText,nRead,objShell
- const ForWriting=2,ForReading=1
- set fso=CreateObject("scripting.FileSystemObject")
- set objShell=CreateObject("WScript.Shell")
- datefile=fso.GetParentFolderName( _
- WScript.ScriptFullName) & "\date.dat"
- if not fso.FileExists(datefile) then
- MsgBox "注意:当前目录下未发现date.dat,视为脚本首次运行。" &_
- vbNewLine & vbNewLine & "date.dat记录着星期五重复的次数," &_
- "必要时可手动更改,现在会将当前系统日期记为真实日期。" _
- ,vbInformation,"提醒"
- set objText=fso.OpenTextFile(datefile,ForWriting,true)
- objText.WriteLine(0)
- objText.Close
- end if
- set objText=fso.OpenTextFile(datefile,ForReading,false)
- nRead=objText.ReadLine
- objText.Close
- set objText=fso.OpenTextFile(datefile,ForWriting,true)
- if Weekday(Date,vbMonday)>5 then
- if nRead=3 then
- objShell.Run "cmd /c date " & DateAdd("d",2,Date),0,true
- objText.WriteLine(0)
- else
- objShell.Run "cmd /c date " & DateAdd("d",5-Weekday(Date,vbMonday),Date),0,true
- objText.WriteLine(nRead+Weekday(Date,vbMonday)-5)
- end if
- else
- objText.WriteLine(0)
- end if
- objText.Close
复制代码
|