Note that there are some explanatory texts on larger screens.

plurals
  1. POvbscript : fso.opentextfile permission denied
    text
    copied!<p>In my code segment, when I script the file name, it gives me a permission denied on the following line: </p> <pre><code>Set objTextFile = objFSO.OpenTextFile(strDirectory &amp; strFile, ForAppending, True) </code></pre> <p>Here is the script </p> <pre><code>'output log info Function OutputToLog (strToAdd) Dim strDirectory,strFile,strText, objFile,objFolder,objTextFile,objFSO strDirectory = "c:\eNet" strFile = "\weeklydel.bat" 'strText = "Book Another Holiday" strText = strToAdd ' Create the File System Object Set objFSO = CreateObject("Scripting.FileSystemObject") ' Check that the strDirectory folder exists If objFSO.FolderExists(strDirectory) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFolder = objFSO.CreateFolder(strDirectory) 'WScript.Echo "Just created " &amp; strDirectory End If If objFSO.FileExists(strDirectory &amp; strFile) Then Set objFolder = objFSO.GetFolder(strDirectory) Else Set objFile = objFSO.CreateTextFile(strDirectory &amp; strFile) 'Wscript.Echo "Just created " &amp; strDirectory &amp; strFile End If set objFile = nothing set objFolder = nothing ' OpenTextFile Method needs a Const value ' ForAppending = 8 ForReading = 1, ForWriting = 2 Const ForAppending = 2 Set objTextFile = objFSO.OpenTextFile(strDirectory &amp; strFile, ForAppending, True) ' Writes strText every time you run this VBScript objTextFile.WriteLine(strText) objTextFile.Close End Function </code></pre> <p>I have assigned the vbscript domain administrator permissions. Any ideas? </p> <p>thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload