I've been looking to answer this exact question and from my research, DiryBoy's response seems to be accurate. Just set SOURCEDIR and OUTPUTZIP.įilename: ZipUp.bat echo Set fso = CreateObject("Scripting.FileSystemObject") > _zipup.vbsĮcho InputFolder = fso.GetAbsolutePathName((0)) > _zipup.vbsĮcho ZipFile = fso.GetAbsolutePathName((1)) > _zipup.vbsĮcho CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) > _zipup.vbsĮcho Set objShell = CreateObject("Shell.Application") > _zipup.vbsĮcho Set source = objShell.NameSpace(InputFolder).Items > _zipup.vbsĮcho objShell.NameSpace(ZipFile).CopyHere(source) > _zipup.vbsĮcho ' Keep script waiting until compression is doneĮcho Do Until objShell.NameSpace( ZipFile ).Items.Count = objShell.NameSpace( InputFolder ).Items.Count > _zipup.vbsĬScript _zipup.vbs %SOURCEDIR% %OUTPUTZIP%Īlternatively, you can parametrize this file by replacing the line CScript _zipup.vbs %SOURCEDIR% %OUTPUTZIP% with CScript _zipup.vbs %1 %2, in which case it can be even more easily called from by simply calling CALL ZipUp C:\Source\Dir C:\Archive.zip. There isn't any need for any third-party tools or dependencies. ![]() You can use a VBScript script wrapped in a BAT file.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |