麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > VBScript > 正文

用vbs實現zip功能的腳本

2020-07-26 11:59:07
字體:
來源:轉載
供稿:網友
壓縮: 
Function fZip(sSourceFolder,sTargetZIPFile) 
'This function will add all of the files in a source folder to a ZIP file 
'using Windows' native folder ZIP capability. 
Dim oShellApp, oFSO, iErr, sErrSource, sErrDescription 
Set oShellApp = CreateObject("Shell.Application") 
Set oFSO = CreateObject("Scripting.FileSystemObject") 
'The source folder needs to have a / on the End 
If Right(sSourceFolder,1) <> "/" Then sSourceFolder = sSourceFolder & "/" 
On Error Resume Next  
'If a target ZIP exists already, delete it 
If oFSO.FileExists(sTargetZIPFile) Then oFSO.DeleteFile sTargetZIPFile,True  
iErr = Err.Number 
sErrSource = Err.Source 
sErrDescription = Err.Description 
On Error GoTo 0 
If iErr <> 0 Then    
fZip = Array(iErr,sErrSource,sErrDescription) 
Exit Function 
End If 
On Error Resume Next 
'Write the fileheader for a blank zipfile. 
oFSO.OpenTextFile(sTargetZIPFile, 2, True).Write "PK" & Chr(5) & Chr(6) & String(18, Chr(0)) 
iErr = Err.Number 
sErrSource = Err.Source 
sErrDescription = Err.Description 
On Error GoTo 0 
If iErr <> 0 Then    
fZip = Array(iErr,sErrSource,sErrDescription) 
Exit Function 
End If 
On Error Resume Next  
'Start copying files into the zip from the source folder. 
oShellApp.NameSpace(sTargetZIPFile).CopyHere oShellApp.NameSpace(sSourceFolder).Items 
iErr = Err.Number 
sErrSource = Err.Source 
sErrDescription = Err.Description 
On Error GoTo 0 
If iErr <> 0 Then    
fZip = Array(iErr,sErrSource,sErrDescription) 
Exit Function 
End If 
'Because the copying occurs in a separate process, the script will just continue. Run a DO...LOOP to prevent the function 
'from exiting until the file is finished zipping. 
Do Until oShellApp.NameSpace(sTargetZIPFile).Items.Count = oShellApp.NameSpace(sSourceFolder).Items.Count 
   WScript.Sleep 1500'如果不成功,增加一下秒數 
Loop 
fZip = Array(0,"","") 
End Function  

Call fZip ("C:/vbs","c:/vbs.zip")  



解壓縮: 
Function fUnzip(sZipFile,sTargetFolder) 
'Create the Shell.Application object 
Dim oShellApp:Set oShellApp = CreateObject("Shell.Application") 
'Create the File System object 
Dim oFSO:Set oFSO = CreateObject("Scripting.FileSystemObject") 
'Create the target folder if it isn't already there 
If Not oFSO.FolderExists(sTargetFolder) Then oFSO.CreateFolder sTargetFolder 
'Extract the files from the zip into the folder 
oShellApp.NameSpace(sTargetFolder).CopyHere oShellApp.NameSpace(sZipFile).Items 
'This is a seperate process, so the script would continue even if the unzipping is not done 
'To prevent this, we run a DO...LOOP once a second checking to see if the number of files 
'in the target folder equals the number of files in the zipfile. If so, we continue. 
Do 
WScript.Sleep 1000‘有時需要更改 
Loop While oFSO.GetFolder(sTargetFolder).Files.Count < oShellApp.NameSpace(sZipFile).Items.Count 
End Function 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 欧美精品一区自拍a毛片在线视频 | 国产精品成人一区二区三区吃奶 | 国产午夜精品久久久久久免费视 | 国产成人av免费观看 | 91av久久 | 国产一级一片免费播放 | 国产九色在线观看 | 免费毛片在线视频 | 极品大长腿啪啪高潮露脸 | 91 久久| 手机国产乱子伦精品视频 | 91精品国产乱码久久桃 | 天天夜干 | 欧美激情精品久久久久 | 日韩在线播放一区二区 | 91精品久久久久久久久网影视 | 久久亚洲激情 | 亚洲精品欧美二区三区中文字幕 | 北原夏美av | 91久久久久久久 | 国产影院在线观看 | 黄色毛片观看 | 成人福利在线 | 欧美一级成人一区二区三区 | h色视频在线观看 | 九九久久视频 | 欧美一级全黄 | 国产精品美女久久久免费 | 全黄性性激高免费视频 | 一级免费大片 | 国产精品视频自拍 | 国产一级在线免费观看 | 免费看黄色一级大片 | 性生活香蕉视频 | 男人的天堂色偷偷 | 亚州综合网 | 欧美成人理论片乱 | 亚洲成人高清电影 | 久久人人97超碰国产公开结果 | 久久精品女人天堂av | 少妇一级淫片高潮流水电影 |