国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

vbs復制文件的腳本

2019-10-26 18:01:14
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:

parentfolder = "c:/"
sourcefile = "c:/windows/log.log"
targetfolder = parentfolder & date & "/"
set objshell = createobject("shell.application")
set objfolder = objshell.namespace(parentfolder)
objfolder.newfolder date
set so=createobject("scripting.filesystemobject")
so.getfile(sourcefile).copy(targetfolder)


經過最近的需要寫出了如下代碼,可以判斷文件是否更新并且文件大小更大

復制代碼 代碼如下:

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
set fn2=fso.GetFile("c:/index2.htm")
flsize2=fn2.size
fldate2=fn2.datelastmodified
set fn=fso.GetFile("c:/index.htm")
flsize1=fn.size
fldate1=fn.datelastmodified
If fso.FileExists("c:/index2.htm") and flsize2>50000 and fldate2>fldate1 Then
fso.getfile("c:/index2.htm").copy("c:/index.htm")
if err.number=0 then WriteHistory "成功"&now(),"log.txt"
end if

Sub WriteHistory(hisChars, path)
  Const ForReading = 1, ForAppending = 8
  Dim fso, f
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile(path, ForAppending, True)
  f.WriteLine hisChars
  f.Close
End Sub



下面來個功能更多的代碼:

復制代碼 代碼如下:

WScript.Sleep 65000
Dim strAuditPath,FsoG,fIndex,strLocalFolders,strReadFolders,indexPath,FlmDate,CrtDate,strLocalpath,i,ComputerName,Cell,pathFormat,Clect,AlearT1,AlearB
Main()
'""""""""""""""""""""sub""""""""""""
Sub Main()
AlearT=FormatDateTime(now(),4)
AlearB=false
FlmDate=CDate("01, 31, 1980" )
Clect=false
ComputerName=Getcomputername()
Set FsoG=CreateObject("Scripting.FileSystemObject")
GetSetting
'pathFormat=Left(strLocalpath,Len(strLocalpath)-8) & "Labels"
indexPath=strAuditPath & "Index.txt"
set f=FSOG.OPENTEXTFILE(GetAbPath(strAuditPath) & "logo history.txt",8,true)
f.writeline FormatDateTime(Now(),4) & "/" & cell & "/" & computername
f.close
'***************計算本地FORMAT****************************************************************************
' Getformat
'**************************************************************************************************************
'在這里一個循環比較日志更新日期
do while(1)
   If (fsoG.FileExists(indexPath)) Then
    '指出最近更新時間
   set fIndex=fsoG.GetFile(indexPath)
   CrtDate=fIndex.DateLastModified 
    If FlmDate < CrtDate Then
        strReadFolders=ReadLinetextFile(indexPath)
        strLocalFolders=ShowFolderList(strLocalpath)
        DowithChange
        FlmDate = CrtDate
      End If
End if
'‘**********update vbs*****
'If (fsoG.FileExists(getAbpath(strAuditPath) & "pe.vbs")) Then
'fsog.CopyFile getAbpath(strAuditPath) & "pe.vbs",GetAbpath(GetCPath) & "pe.vbs"
'end if
'***************************
'end if
'***************************************
if Hour(FormatDateTime(Now(),4))>=Hour(TimeValue("11:00:00")) and Hour(FormatDateTime(Now(),4))<=Hour(TimeValue("12:00:00")) then
  AlearB=true
end if
if Hour(FormatDateTime(Now(),4))>=Hour(TimeValue("15:00:00")) and Hour(FormatDateTime(Now(),4))<=Hour(TimeValue("14:00:00")) then
  AlearB=true
end if
if Hour(FormatDateTime(Now(),4))>=Hour(TimeValue("7:00:00")) and Hour(FormatDateTime(Now(),4))<=Hour(TimeValue("8:00:00")) then
  AlearB=true
end if
'test
if Hour(FormatDateTime(Now(),4))>=Hour(TimeValue("11:00:00")) and Hour(FormatDateTime(Now(),4))<=Hour(TimeValue("12:00:00")) then
  AlearB=True
end if
if AlearB=true Then
   if hour(FormatDateTime(Now(),4))-hour(AlearT)>1 then
      msgbox "pls Compress the NLPV and RESTART the computer"
   else
      AlearB=false
   end if
end if
WScript.Sleep 10000
Loop
End Sub
Sub Getformat()
strFormats=ShowFilesList(pathFormat)
  Const ForReading = 1, ForWriting = 2
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile(GetAbPath(strAuditPath) & CELL & " " & ComputerName  & ".txt", ForWriting, True)
for i=0 to UBound(strFormats)
f.WriteLine  left(strFormats(i),len(strFormats(i))-4)
next
f.WriteLine cell
f.WriteLine ComputerName
'
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜兴市| 长宁区| 将乐县| 尚义县| 措勤县| 富平县| 江北区| 栖霞市| 长沙市| 高要市| 昭平县| 双牌县| 山东省| 上蔡县| 神池县| 玉溪市| 阳江市| 滨海县| 新津县| 江城| 镇江市| 垦利县| 通城县| 千阳县| 阜平县| 宁国市| 古田县| 金溪县| 若尔盖县| 科技| 合山市| 新巴尔虎左旗| 中卫市| 梨树县| 名山县| 乌兰察布市| 南昌市| 延吉市| 邯郸县| 滦平县| 英吉沙县|