Пример скрипта на vbs, разберетесь или нет, не знаю:
Set FileSytemObject = CreateObject("Scripting.FileSystemObject")
'/// Получаем путь до каталога, в котором находимся
ParentFolderName = FileSytemObject.GetParentFolderName(Wscript.ScriptFullName)
'/// Строим путь для создания тестового файла
SourceFilePath = FileSytemObject.BuildPath(ParentFolderName, "Текстовый документ. txt")
'/// Создаём и заполняем файл содержимым
FileSytemObject.OpenTextFile(SourceFilePath, 2, True).write "Содержимое файла"
'/// Строим путь для создания архива
DestFilePath = FileSytemObject.BuildPath(ParentFolderName, "1.zip")
'/// Создаём класс создания ZIP файла
Set Zip = New ZipClass
'/// Создаём новый архив
Zip.CreateArchive DestFilePath
'/// Добавляем файл в архив
Zip.CopyFileToArchive SourceFilePath
'/// Закрываем архив
Zip.CloseArchive
MsgBox "Архив создан", vbInformation, "ZipClass"
Class ZipClass
Private Shell
Private FileSystemObject
Private ArchiveFolder
Private ItemsCount
Private Sub Class_Initialize()
Set Shell = CreateObject("Shell.Application")
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
End Sub
Function CreateArchive(ZipArchivePath)
If UCase(FileSystemObject.GetExtensionName(ZipArchivePath)) <> "ZIP" Then
Exit Function
End If
Dim ZipFileHeader
ZipFileHeader = "PK" & Chr(5) & Chr(6) & String(18, 0)
FileSystemObject.OpenTextFile(ZipArchivePath, 2, True).Write ZipFileHeader
Set ArchiveFolder = Shell.NameSpace(ZipArchivePath)
If Not (ArchiveFolder is Nothing) Then CreateArchive = True
End Function
Function CopyFileToArchive(FilePath)
If (ArchiveFolder Is Nothing) Then Exit Function
ArchiveFolder.CopyHere FilePath
ItemsCount = ItemsCount + 1
End Function
Function CopyFolderToArchive(FolderPath)
If (ArchiveFolder Is Nothing) Then Exit Function
ArchiveFolder.CopyHere FolderPath
ItemsCount = ItemsCount + 1
End Function
Function CloseArchive
If (ArchiveFolder is Nothing) Then Exit Function
Set WsriptShell = CreateObject("Wscript.Shell")
If IsObject(Wscript) Then
Do
Wscript.Sleep 100
Loop Until ArchiveFolder.Items.Count => ItemsCount
Else
ServerSleep
End if
ItemsCount = 0
End Function
Private Function ServerSleep
Set WsriptShell = CreateObject("Wscript.Shell")
Do
WsriptShell.Popup "", 1, ""
Loop Until ArchiveFolder.Items.Count => ItemsCount
End Function
Function MoveFileToArchive(FilePath)
If (ArchiveFolder is Nothing) Then Exit Function
ArchiveFolder.MoveHere FilePath
End Function
End Class
Другие языки программирования и технологии
плиииииииз помогите пожалуйста, срочно. . Написать скрипт, выполняющий архивацию файлов и каталогов..
Какой язык скрипта????
Похожие вопросы
- Пожалуйста, помогите!!! Нужно срочно написать программу в VB. Задание тут:
- Задали по украинскому языку написать целый лист А4 "просторічних слів" помогите пожалуйста срочно!!!!
- Помогите пожалуйста срочно!
- Помогите нужно срочно написать задачу на паскале))
- Помогите пожалуйста СРОЧНО, проблема с переустановкой windows7
- помогите пожалуйста!!3.Напишите процедуру Input(A) для заполнения массива целых чисел A размером 10 x 10: 0 0 0 ...0 0
- помогите пожалуйста срочно надо
- Помогите пожалуйста! Срочно нужно! Весь интернет прошарила.
- Помогите, пожалуйста, срочно надо (С#).
- ПОМОГИТЕ ПОЖАЛУЙСТА СРОЧНО НАДО А ЯЗЫКЕ С++