import os, zipfile, sys, appuifw dirString = u'E:\\Documents\\wrtdev\\' wgzString = u'AppFolder' def addDir(arg, d, fn): global z for item in fn: rel = d.replace(arg, '') fullName = d + '\\' + item fullName = fullName.encode('ascii', 'replace') arcName = rel + '\\' + item arcName = arcName.encode('ascii', 'replace') z.write(fullName, arcName) zipPath = dirString + wgzString + u'.zip' if os.path.exists(zipPath): os.remove(zipPath) print 'removing old archive first' z = zipfile.ZipFile(zipPath, 'w') os.path.walk(dirString + wgzString, addDir, dirString) z.printdir() z.close() wgzPath = dirString + wgzString + u'.wgz' if os.path.exists(wgzPath): os.remove(wgzPath) os.rename(zipPath, wgzPath) launcher = appuifw.Content_handler() launcher.open(wgzPath)