source
<HTA:APPLICATION>

<script type="text/javascript">
window.onload=function(){
alert("Web-based hta's will write to the system or system32 folder");
return;
}
  function writeFile()
  // assumes: this file is a HTML Application
  // action:  creates a text file called "hello.txt" and write the string
  //          "Hello" to it
  {
     var b, fs;

     fs = new ActiveXObject("Scripting.FileSystemObject");
     b  = fs.CreateTextFile("C:\hello.txt", true);
    var msg=document.getElementById('oInputSrc').value;
  	msg = msg==''?"Default":msg;
//     b.WriteLine("Hello");
     b.WriteLine(msg);
     b.Close();
     return;
  }
</script>
</head>
<body scroll="no">
<h3>Create and Write to a File</h3>
<a href='http://users.fmg.uva.nl/rgrasman/programming/HTA_Programming.html'>source</a><br />
<input type="submit" id="btnQuit" value="Quit App" onclick="window.close();" />
<input type="submit" id="Create" value="Create" onclick="writeFile();" /><br />
<input type='text' id='oInputSrc' />