vbscript - Compressed (zip) Cannot create output file - error -



vbscript - Compressed (zip) Cannot create output file - error -

i using vbscript scan folders, create zip files , add together files them (compress), run script on folders lot of files, next error: "compressed (zip) cannot create output file"

my zip handling code follows:

dim objfso set objfso= createobject("scripting.filesystemobject" function preformzip(objfile,target,zip_name, number_of_file) set shell = createobject("wscript.shell") zip_target = target + "\" + zip_name +".zip" if not objfso.fileexists(zip_target) makepathifnotexist(target) newzip(zip_target) else if number_of_file=0 objfso.deletefile(zip_target) newzip(zip_target) end if end if set zipapp = createobject("shell.application") asourcename = split(objfile, "\") ssourcename = (asourcename(ubound(asourcename))) zip_file_count = zipapp.namespace(zip_target).items.count zipapp.namespace(zip_target).copyhere objfile, 16 on error resume next sloop = 0 until zip_file_count < zipapp.namespace(zip_target).items.count wscript.sleep(100) sloop = sloop + 1 loop on error goto 0 end function sub newzip(zip) set new_zip = objfso.createtextfile(zip) new_zip.write chr(80) & chr(75) & chr(5) & chr(6) & string(18, 0) new_zip.close set new_zip = nil wscript.sleep(5000) end sub function makepathifnotexist(dirpath) dim fso, adirectories, screatedirectory, idirectory set fso = createobject("scripting.filesystemobject") if fso.folderexists(dirpath) exit function end if adirectories = split(dirpath, "\") screatedirectory = adirectories(0) idirectory = 1 ubound(adirectories) screatedirectory = screatedirectory & "\" & adirectories(idirectory) if not fso.folderexists(screatedirectory) fso.createfolder(screatedirectory) end if next end function function recursion(directorypath) dim fso : set fso = createobject("scripting.filesystemobject") if fso.folderexists(directorypath) exit function phone call recursion(fso.getparentfoldername(directorypath)) fso.createfolder(directorypath) end function

i first thought i'm not waiting long plenty after creating zip, tried 10 seconds wait after each zip , still same error.

how can solve it?

if there no solution, there alternative way create zip? script not own utilize don't want ro relay on software needs installed?

although folder.copyhere method not homecoming value , no notification given calling programme indicate re-create has completed, wait next code snippet , hope can see proper (re)placement in script:

on error goto 0 zipapp.namespace(zip_target).copyhere objfile _ , 4 +8 +16 +256 +512 +1024 wscript.sleep( 100) on error goto 0

notice: no waiting do..loop, wscript.sleep( 100) sufficient zip little files or start progress dialog box in case of huge files - , script wait it...

notice: no 'on error resume next. avoid invoking on error resume next if not handle errors...

flags used follows.

const fof_silent = &h0004 'ineffective? const fof_renameoncollision = &h0008 'ineffective? const fof_noconfirmation = &h0010 ' const fof_simpleprogress = &h0100 'ineffective? const fof_noconfirmmkdir = &h0200 ' const fof_noerrorui = &h0400 '

unfortunately, in cases, such compressed (.zip) files, alternative flags may ignored design (sic!) msdn!

if fof_silent flag ineffective, user cancel zipping process...

if fof_renameoncollision flag ineffective, newer file of same name not zipped, existing zip file keeps previous version without caution against; existing folder brings on error message...

those fixed well, it's subject of question...

vbscript zip

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -