title: Writing json string into file using Windows Script Host
body: <p><br/>
  I am trying to write json string that I stringified using <a href="https://github.com/douglascrockford/JSON-js/blob/master/json2.js" rel="nofollow">https://github.com/douglascrockford/JSON-js/blob/master/json2.js</a> ( JSON.stringify) ,</p>
  
  <p>I am trying to save the string and I am getting an error:</p>
  
  <blockquote>
    <p>Microsoft JScript Runtime Error: Invalid procedure call or argument</p>
  </blockquote>
  
  <p>at</p>
  
  <pre><code>var textStream = fileObj.OpenAsTextStream(ForWriting, TristateFalse); 
  </code></pre>
  
  <p>this is my code :</p>
  
  <pre><code>var pref = JSON.parse(textPref);
  textPref = JSON.stringify(pref);
  WSH.echo(textPref)
  
  // Create the new file.
  fso.CreateTextFile("d:\\Preferences_temp", true);
  var fileObj = fso.GetFile("d:\\Preferences_temp");
  var textStream = fileObj.OpenAsTextStream(ForWriting, TristateFalse); &lt;- Microsoft JScript Runtime Error: Invalid procedure call or argument
  textStream.Write(textPref);
  textStream.Close();
  </code></pre>