title: HTA Error: Could not complete the operation due to error 8070000c
body: <p>So, I have an HTA that I am having problems with when trying to create or open a text file to log.</p>
  
  <p>It works fine on Windows 7 64bit on IE 11.
  When I try it on Windows 10 64bit, I get the following error:</p>
  
  <p><strong>Could not complete the operation due to error 8070000c.</strong></p>
  
  <p>The line the error is on is below:</p>
  
  <pre><code>   var fso = new ActiveXObject("Scripting.FileSystemObject");
     var f = fso.OpenTextFile('log\\log.txt',2,true); // &lt;-- Error is on this line!
  </code></pre>
  
  <p>It seems to be like a permission error. I've searched for about 2 hours and can't figure out what is the cause / solution.</p>
  
  <p>Again, it works fine on Windows 7, but not on Windows 10.</p>
  
  <p>Same HTA is below:</p>
  
  <pre><code>&lt;!-- saved from url=(0014)about:internet --&gt;
  &lt;?xml version='1.0' encoding='UTF-8'?&gt;
  &lt;!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'&gt;
  &lt;html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'&gt;
  &lt;head&gt;
  &lt;HTA:Application Border='yes' ContextMenu='no' Caption='no' Scroll='auto' Singleinstance='yes' Windowstate='maximize' application='yes'&gt;
  &lt;meta http-equiv='Content-Type' content='text/html; charset=utf-8' /&gt;
  &lt;meta http-equiv='X-UA-Compatible' content='IE=9' /&gt;
  &lt;title&gt;KIOSK&lt;/title&gt;
  &lt;link rel='stylesheet' href='css/style.css'&gt;
  &lt;link rel='stylesheet' href='https//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css'&gt;
  &lt;script type='text/javascript' src='jQuery/jquery-3.1.0.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript'&gt;
      // Log File.
      function writeToLog(dStamp, msg) {
          var loc = window.location.pathname;
          var dir = loc.substring(0, loc.lastIndexOf('\\'));
          dir = dir + '\\log\\log.txt';
          // alert(dir);
          //Create FSO Object
          var fso = new ActiveXObject("Scripting.FileSystemObject");
          //First, make sure the LOG exists
          if (!fso.fileExists("log\\log.txt")) {
              //alert("FILE DONT EXIST!");
              try {
                  var f = fso.OpenTextFile(dir,2,true);
                  f.close();
              } catch(e) {
                  alert("The following error was found: " + e);
                  return;
              }
          } else {
              dtTime = new Date();
              //This function was added because if the log file gets over a certain size, I want to rename it and make a new one
              var f = fso.OpenTextFile(dir,1,false);
              var fSize = f.Size;
              if (fSize &gt; 1000000) { //If file is larger than 1Mb, rename and create new.
                  fileExists = true;
                  fileNumber = 0;
                  newFileName = f + "-" + (dtTime.getMonth() + 1) + "-" + dtTime.getDate() + "-" + dtTime.getFullYear();
                  while (fileExists) {
                      if (fso.fileExists(newFileName)) {
                          fileNumber++;
                          newFileName = f + "-" + (dtTime.getMonth() + 1) + "-" + dtTime.getDate() + "-" + dtTime.getFullYear() + "_" + fileNumber;
                          fileExists = true;
                      } else {
                          fileExists = false;
                      }
                  }
  
                  fso.MoveFile(f, newFileName);
  
                  //And create my new one
                  f = fso.OpenTextFile(dir,2,true);
                  f.close();
              }
          }
  
          //Now, open the log file
          var f = fso.OpenTextFile(dir, 8);
  
          //Now, write to the log file
          //First, check to see if we want a date stamp before this message
          if (dStamp == true) {
              dtTime = new Date();
              nLine = dtTime + "\t" + msg;
          } else {
              nLine = "\t" + msg;
          }
  
          f.WriteLine(nLine);
  
          //Finally, close the log file... until next time...
          f.close();
      }
  &lt;/script&gt;
  &lt;body ondragstart='return false' style='text-align:center;'&gt;
      &lt;input type="button" onclick="writeToLog(true,'Test Log HTA');" value="Test Log" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any help is appreciated.</p>