title: Progress bar on Copy Folder VBS
body: <p>I have the following HTA using VBScript to copy a folder from one source folder to a destination folder. I also have a, so far not working, progress bar made in CSS and JavaScript to show the progress. The script is copying the folder succesfully, but I have not found a way to show the progress.</p>
  
  <p><strong>I need to find a way to show the actual progress in the progress bar when copying the folder.</strong> I have tried with various methods using the statement <code>For Each File In Folder</code> but without luck.</p>
  
  <p>I know there are other methods of showing a progress bar, i.e the Windows progress bar, but I would like to use my own.</p>
  
  <p>The following code samples are in one HTA, but I've dividede the sciprts up for better overview. Hope that helps.</p>
  
  <p>The following code is the acutal copy folder VBScript:</p>
  
  <pre><code>&lt;script language="vbscript"&gt;
  Sub Setup
  Dim FSO, NewFile, ThisFile
  Set FSO = CreateObject("Scripting.FileSystemObject")
  FolderDir = FSO.GetFolder("..\")
  
  dim WSHShell, desktop, pathstring, objFSO
  set objFSO = CreateObject("Scripting.FileSystemObject")
  Set WSHshell = CreateObject("WScript.Shell")
  desktop = WSHShell.SpecialFolders("Desktop")
  Destination = objFSO.GetAbsolutePathName(desktop)
  
  Source = "C:\Test\Source"
  
  FSO.CopyFolder ""&amp;Source&amp;"", ""&amp;Destination&amp;"\", True
  End Sub
  
  Sub CloseApp
  Self.Close
  End Sub
  
  &lt;/script&gt;
  </code></pre>
  
  <p>The copy script is triggered by the onClick on an image in the HTA script:</p>
  
  <pre><code>&lt;HTA:APPLICATION ApplicationName="UPDATE" CAPTION="NO" SCROLL="NO" INNERBORDER="NO" SINGLEINSTANCE="YES" ICON="../images/icon_64.ico" ShowInTaskbar="YES"&gt;
  
  &lt;body onload="progressbar(100,75);"&gt;
  &lt;table cellpadding=0 cellspacing=0 width="100%"&gt;
  &lt;tr&gt;
  &lt;td id="top_bar" height="25" width="100%" align="center"&gt;INSTALLATION&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="center"&gt;
  &lt;br&gt;
  &lt;b&gt;Do you want to install the program?&lt;/b&gt;&lt;br&gt;
  &lt;br&gt;
   &lt;div style="width:150px"&gt;
    &lt;div id="slider" align="left"&gt;
     &lt;div id="sliderbar" &gt;&lt;/div&gt;
     &lt;div id="progress" align="center"&gt;&lt;/div&gt;
    &lt;/div&gt;
   &lt;/div&gt;
  &lt;br&gt;
  &lt;img src="../images/installer.png" onclick="Setup()"&gt;&amp;nbsp&amp;nbsp&lt;img src="../images/afslut.png" onclick="CloseApp()"&gt;
  &lt;br&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Furthermore I have a progress bar, which is made in CSS and JavaScript:</p>
  
  <pre><code>&lt;style&gt; 
  #slider{
   width:100%;
   height:12px;
   border:1px solid #000;
   overflow:hidden;
   background: #FFF;
  }
  #sliderbar{
   width:37%;
   height:12px;
   border-right: 1px solid #000;
   background-color: #66FF33;
  }
  #progress {
   font-family: Arial;
   font-size: 10px;
   font-weight: bold;
   position: relative;
   top: -15px;
  }
  &lt;/style&gt;
  
  &lt;script language="JavaScript"&gt;
   function progressbar(XX, YY){
    var progress=Math.round((YY*100)/XX);
     document.getElementById("sliderbar").style.width=progress+'%';
     document.getElementById("progress").innerHTML=progress+'%';
     document.title = progress+'% Installed';
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I really hope that someone here can see an easy way to show use the progress bar. This is my last step in finishing a script, so I would be pleased if someone can help me out.</p>
  
  <p>Thanks for reading!</p>