how can i get vbscript to save changes to a(local) xml file? {path} method gives me 'Access Denied' errors

Posted on 2009-02-11
Last Modified: 2013-12-17
I have written a small IE/vbscript app in Vis.Interdev (VS6), basically a rough database using XML files. All is happy in developer world but when I put the app into the real world it won't save any work.
I can load and manipulate the XML data, but how can i get vbscript to save changes to a(local) xml file?
The {path} method just gives me 'Access Denied' errors.
Question by:OohOohIKnowThisOne
    LVL 29

    Expert Comment

    Make sure the IWAM_YOUR_MACHINE_NAME_HERE user has r/w permission on the folder.
    LVL 54

    Expert Comment


    When you say "real world" what does that mean?  Is this a public website and page?  Is the protocol http or https?  What does IE show for the zone (i.e. trusted, Internet, etc)?

    If an Internet page and it is in that zone for IE then what happens if you have the user add that domain to the Trusted list?  Security settings still may not allow it but that is what I would first try.

    Is this app an  ActiveX object or what exactly?

    Let me know if you have any questions or need more information.


    Accepted Solution

    I  couldn't get the save method to work in the end but did find a way around the issue. It's dirty and left me feeling unclean, but it worked!
    I simply copied the XML to a file, deleting and then overwriting the source document!

    Function SaveDoc(pDocument)
    ' This is a dirty workaround the function which typically won't work
    'for whatever reason

          Dim oSys
          Dim oFile
          dim tURL
          dim tXML
          dim msg
          dim oURL
          dim oPos
          On Error Resume Next
          Set oSys = CreateObject("scripting.filesystemobject")
          If oSys Is Nothing Then
                MsgBox "Failed to create the filesystem object"
                Exit Function
          End If
          select case pDocument
                case DOC_SCORES
                      oURL = gScores.url
                      tXML = gScores.xml
                case DOC_SHOOTERS
                      oURL = gShooters.url
                      tXML = gShooters.xml
                case else
          end select

          'Look for the drive letter indicator :/
          oPos = InStrRev(oURL, ":/")
          tURL = right(oURL,len(oURL) - oPos + 2)
          tURL = Replace(tURL,"/","\")

          if oSys.FileExists(tURL) then
                call oSys.DeleteFile(tURL,true)
          end if
          Set oFile = oSys.CreateTextFile(tURL, True)

          if oFile is nothing then
                msgbox "Save XML document Error: 'oFile is Nothing'"
          end if
          oFile.Write (tXML)

          If Not Err.Number = 0 Then
          MsgBox Err.Description
          On Error GoTo 0
          End If

          Set oFile = Nothing
          Set oSys = Nothing

    End Function

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
    Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
    The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
    Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now