Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:27:35+00:00 2026-05-10T22:27:35+00:00

In my code segment, when I script the file name, it gives me a

  • 0

In my code segment, when I script the file name, it gives me a permission denied on the following line:

Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, ForAppending, True) 

Here is the script

'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 ' & strDirectory     End If      If objFSO.FileExists(strDirectory & strFile) Then        Set objFolder = objFSO.GetFolder(strDirectory)     Else        Set objFile = objFSO.CreateTextFile(strDirectory & strFile)        'Wscript.Echo 'Just created ' & strDirectory & 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 & strFile, ForAppending, True)      ' Writes strText every time you run this VBScript     objTextFile.WriteLine(strText)     objTextFile.Close End Function 

I have assigned the vbscript domain administrator permissions. Any ideas?

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:27:36+00:00Added an answer on May 10, 2026 at 10:27 pm

    I don’t think this has to do with File Permissions per se. It has to do with the fact that you’ve created the file using:

    Set objFile = objFSO.CreateTextFile(strDirectory & strFile) 

    That creates the file…and carries a reference to that file (objFile)

    Then you don’t close the file before you destroy the reference

    ... 'Missing objFile.Close here Set objFile = nothing Set objFolder = nothing ... 

    Consequently you’re destroying the reference but leaving the textstream open in memory thus locking your file.

    You are then proceeding to attempt to re-open the file while the file is already ‘open’. This is a little long winded, you’ve already got a reference after you’ve created the file – it would be easier just to write straight to that rather than destroy the reference before creating another one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Eric White just posted a blog article to do exactly… May 11, 2026 at 9:42 am
  • added an answer See RegistryValues() in the PowerBuilder Help. The following isn't exactly… May 11, 2026 at 9:42 am
  • added an answer My only experiences in queries are with MySQL, but hopefully… May 11, 2026 at 9:42 am

Related Questions

In my code segment, when I script the file name, it gives me a
In my code fprintf returns successfully by returning the number of bytes written in
In my code behind I wire up my events like so: protected override void
In my code, I am creating a collection of objects which will be accessed
In my code, I want to view all data from a CSV in table
In my code attached below, I'm trying to upload a file via ASP.NET. I
In my code i create a HyperLinkField object. Depending on a database field value,
In my code, when a button is clicked the progress bar is set to
In my code I'd like to make my repositories IQueryable. This way, the criteria
in my code i would like boost::shared_ptr not to call delete but call ptr->deleteMe()

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.