title: Inno Setup Copy Files and Folders to an Existing Zip File
body: <p>Is there a way to copy files from a folder to a zip file using Inno Setup?</p>
  
  <p>My installer script creates a Temp Folder and I would like to move the content (mix of files and folders) to an existing zip file.  I don't need compression or anything fancy... </p>
  
  <p>I thought, and I know this is dumb, that this would be possible using FileCopy because (as far as I know) MS Windows treats copying to a zip folder in a similar way as copying to a directory.</p>
  
  <p>[Update 1] Ok - <a href="https://stackoverflow.com/questions/30211/can-windows-built-in-zip-compression-be-scripted/124775#124775">found a vbs script that does what I want</a>, after some minor changes:</p>
  
  <pre><code>Dim fso, winShell, h, MyTarget, MySource
  
  MySource = Wscript.Arguments.Item(0)
  MyTarget = Wscript.Arguments.Item(1)
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set winShell = createObject("shell.application")
  Set h = fso.getFile(MyTarget)
  
  'Wscript.Echo "Adding " &amp; MySource &amp; " to " &amp; MyTarget
  
  winShell.NameSpace(MyTarget).CopyHere winShell.NameSpace(MySource).Items
  
  do
      wscript.sleep 500
      max = h.size
  loop while h.size &gt; max 
  
  Set winShell = Nothing
  Set fso = Nothing
  </code></pre>
  
  <p>And ran it from command line like this:
  Cmd (run as admin)
  C:\MyScriptLocation\WScript ZipScript.vbs "MySourceDirPath" "MyDestDirPath\MyZipFile.zip"</p>
  
  <p>So now I need to get it to run from Inno :-)</p>
  
  <p>[Update 2] Ok - got it running from Inno, revised the script:</p>
  
  <pre><code>Dim objFSO, objTxt, winShell, h
  Dim myFolder, myZipFile
  Const ForWriting = 2
  
  myFolder = Wscript.Arguments.Item(0)
  myZipFile = Wscript.Arguments.Item(1)
  Wscript.Echo "Planning to add Source: " &amp; myFolder &amp; " to Target: " &amp; myZipFile
  
  Set objFSO = CreateObject( "Scripting.FileSystemObject" )
  Wscript.Echo "Creating myZipFile" &amp; myZipFile
  ' Create an empty ZIP file
      Set objTxt = objFSO.OpenTextFile( myZipFile, ForWriting, True )
      objTxt.Write "PK" &amp; Chr(5) &amp; Chr(6) &amp; String( 18, Chr(0) )
      objTxt.Close
      Set objTxt = Nothing
  
  Set winShell = createObject("shell.application")
  Set h = objFSO.getFile(myZipFile)
  Wscript.Echo "Started Copy Process" &amp; myZipFile
  winShell.NameSpace(myZipFile).CopyHere winShell.NameSpace(myFolder).Items, true
  
  do
      wscript.sleep 1000
      max = h.size
  loop while h.size &gt; max 
  
  Set winShell = Nothing
  Set objFSO = Nothing
  </code></pre>
  
  <p>I am running from Inno using:</p>
  
  <pre><code>[Run]
  Filename: "PackItUp.vbs"; Parameters: """{code:GetDataDir_S|0}\Temp"" ""{code:GetDataDir_S|0}\myZip.zip"""; WorkingDir: "{code:GetDataDir_S|0}"; Flags: shellexec runascurrentuser
  </code></pre>
  
  <p>Which seems to work, but I am unsure if this is a good solution.</p>