title: VBScript writing to file error
body: <p>I've coded a script that has the basic function of creating a .txt file and then writing some text into it. But whenever I run it I get; </p>
  
  <p><code>Script: F\Known.vbs
      Line: 17
      Char:1
      Error: Permission denied
      Code: 800A0046
      Source: Microsoft VBScript runtime error</code>  </p>
  
  <p>My code goes as such;</p>
  
  <p><code>Option Explicit
      Dim objFSO, objFSOText, objFolder, r, objFile
      Dim strDirectory, strFile
      Dim objNetwork
      do
      randomize
      r = int(rnd*91372183) + 1
      strDirectory = "C:\Users\" &amp; CreateObject("Wscript.Network").UserName &amp; "\Desktop"
      strFile = "\" &amp; r &amp; ".txt"
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objFile = objFSO.CreateTextFile(strDirectory &amp; strFile)
      Const ReadOnly = 1
      Set objFile = objFSO.GetFile(strDirectory &amp; strFile)
      objFile.Attributes = objFile.Attributes XOR ReadOnly
      Const ForWriting = 2
      Set objNetwork = CreateObject("Wscript.Network")
      Set objFile = objFSO.OpenTextFile(strDirectory &amp; strFile, ForWriting)
      objFile.Write "f672f7fd12d6wf6df26df6f26dfs6f6qf67wqqf6dfw6f16fw76df61f62fd"
      objFile.WriteBlankLines(1)
      loop</code>  </p>
  
  <p>I have looked at other questions of a similar nature, trying to add read-write attributes, etc. but none have worked.</p>