title: How do I write text box to .txt in VBScript?
body: <p>i need to write a text area (box) value to .txt i am getting permissions denied when writing to "input.txt"
  i got got permission denied when writing input.txt from the text box. i edited using suggestions found below and also killed handle for input.txt using process explorer.</p>
  
  <p>using the code below i can now save textbox text to text file input.txt.
  i also figured out how to call upon a batch file to change that text into a cyphered form, and then i added a refresh button to open that changed text into a second textbox as a final output result which leaves the text now capable of being password encrypted after being saved in input.txt and opened in a second textbox from file SR-Encrypted.txt after being cyphered via batch file encrypter.bat then by refreshing the page using the refresh button i added..</p>
  
  <p>thank you agnar!</p>
  
  <pre><code>    &lt;html&gt;
      &lt;script language="vbscript"&gt;
  option explicit
      Const ForWriting = 2
  
      Dim objFSO, objFile, strFileName, objshell
      strFileName = "input.txt"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
  
  Set objShell = CreateObject("WScript.Shell")
  
  Sub Submitarea
    Set objFile = objFSO.OpenTextFile(strFileName, 2, True)
    objfile.Write TextFile.Value
    objFile.Close
    MsgBox "Your text has been added to " &amp; strFileName, 64, "Textarea Input"
  End Sub
  &lt;/script&gt;   
  &lt;/html&gt;
    &lt;/head&gt;
      &lt;title&gt;Example&lt;/title&gt;
      &lt;script language="VBScript"&gt; 
        Sub test
       set oFSO=CreateObject("Scripting.FileSystemObject")
       set oFile=oFSO.OpenTextFile("SR-Encrypted.txt",1)
       text=oFile.ReadAll
       document.all.ScriptArea.value=text
       Set objFile = nothing
       oFile.Close
        End Sub 
      &lt;/script&gt;
    &lt;/head&gt;
  
    &lt;script language="vbscript"&gt;
  Option Explicit
  
  ' This is the Sub that opens external files and reads in the contents.
  ' In this way, you can have separate files for data and libraries of functions
  Sub Include(yourFile)
    Dim oFSO, oFileBeingReadIn   ' define Objects
    Dim sFileContents            ' define Strings
  
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFileBeingReadIn = oFSO.OpenTextFile("try.vbs", 1)
    sFileContents = oFileBeingReadIn.ReadAll
    oFileBeingReadIn.Close
    ExecuteGlobal sFileContents
  End Sub
  
  ' Here we call the Include Sub, then pass it the name of the file we want items from
  Include "mySubLib"
  
  &lt;/script&gt;
    &lt;body&gt;
      &lt;button onClick="test()"&gt;Refresh Message Encrypter-Decrypter&lt;/button&gt;
    &lt;/body&gt;
  &lt;/html&gt;
      &lt;/head&gt;
   &lt;/html&gt;
  &lt;body&gt;
      &lt;h1&gt;Write File&lt;/h1&gt;
      &lt;p&gt;How to Write to a File.&lt;/p&gt;
  
      &lt;textarea name="TextFile" id="TextFile" rows="20" cols="50"&gt;&lt;/textarea&gt;
  
      &lt;input type="button" value="Submit" onclick="Submitarea"&gt;
  
  &lt;/body&gt;
      &lt;body&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>