[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2009-02-11
Medium Priority
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 xmldoc.save {path} method just gives me 'Access Denied' errors.
Question by:OohOohIKnowThisOne
LVL 29

Expert Comment

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

Expert Comment

ID: 23614816

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

OohOohIKnowThisOne earned 0 total points
ID: 23873985
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 xmldoc.save 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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

834 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