Results 1 to 16 of 16

Thread: [RESOLVED] VBScript errors with 'Access is Denied'

  1. #1
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Resolved [RESOLVED] VBScript errors with 'Access is Denied'


    We have a .net application in our project that is giving me problems on my machine. Part of the app calls various .vbs files to perform batch operations - zipping files and moving them around mostly. The code works on the original developer's machine, but it errors on mine - throwing up a message box. The msgbox title says "Compressed (zipped) Folders Error", while the msgbox itself says 'Unable to complete the operation' and 'Access is Denied'.

    Has anyone seen anything like this before? I'm wondering if the message I'm getting is a red-herring.

    Here's one of the scripts:
    Code:
    Dim fso, winShell, MyTarget, MySource, file
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set winShell = createObject("shell.application")
    
    'find the current dir
    dim CurDir, oShell
    Set oShell = CreateObject("WScript.Shell")
    CurDir = oShell.CurrentDirectory
    
    
    'get source and target paths
    MyTarget = fso.GetParentFolderName(curdir) & "\zip\copy.qd_calculator.zip"
    MySource = fso.GetParentFolderName(CurDir) & "\standalone\calculator\"
    
    
    'delete the old file, if it exists
    if fso.FileExists(MyTarget) then
        fso.DeleteFile mytarget, true
    end if
    
    'create a new clean zip archive
    Set file = fso.CreateTextFile(MyTarget, True)
    file.write("PK" & chr(5) & chr(6) & string(18,chr(0)))
    file.close
    
    winShell.NameSpace(MyTarget).CopyHere winShell.NameSpace(MySource).Items
    
    do until winShell.namespace(MyTarget).items.count = winShell.namespace(MySource).items.count
        wscript.sleep 1000 
    loop
    
    Set winShell = Nothing
    Set fso = Nothing
    
    MsgBox("Calculator copy zipped to:" & vbcrlf & MyTarget)
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  2. #2
    New Member
    Join Date
    Oct 12
    Posts
    4

    Re: VBScript errors with 'Access is Denied'

    Hi have you looked into things outside of the vb realm?
    For instance permissions issues? Writer may be on xp and you on Win7. Writer may be admin on local machine and you user. What are your rights do directories on the machine? These types of things seem likely to be the issue as much as anything.

  3. #3
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    See, that's what I don't understand. I'm an admin on my machine and have full control over the directories in question - except the zip file that get's created. I can neither open it nor delete it - it says I need administrative permission to do so.

    I never have understood windows security.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,789

    Re: VBScript errors with 'Access is Denied'

    Can you open the zip manually? outside of the app?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  5. #5
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    Nope. It says I need to be an administrator to do that - which I am.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,789

    Re: VBScript errors with 'Access is Denied'

    sounds like a file ownership issue... but I wouldn't know how to change that or what would need to be changed in the code.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  7. #7
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    After putting in some msgboxes, it seems the offending line is:

    winShell.NameSpace(MyTarget).CopyHere winShell.NameSpace(MySource).Items

    It seems to start copying some of the files from the source directory to the target zipfile, but then fails at some point.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  8. #8
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    It's interesting. The script seems to have the permission to delete the existing zip file - even if the zip file has no permissions set for it - but fails somehow in the adding of files to the zip file after recreating it. The script will add some files to the zip file, but not all of an individual file will get copied to the zip file before the script throws the error about access denied and gives up.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,789

    Re: VBScript errors with 'Access is Denied'

    could it be permissions on the file you're trying to add?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  10. #10
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    I don't think so. I created a test directory with a text file in it that just had 'hello world' in the text file, and pointed my script to that directory instead. It gave me the same error - although it did succeed in getting the file copied to the zip file. I looked at the 'test' text file I created and nothing appeared amiss.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  11. #11
    New Member
    Join Date
    Oct 12
    Posts
    4

    Re: VBScript errors with 'Access is Denied'

    Is it copying or moving? If moving it may be erroring due to not having permissions to delete the original file.

    Get your permissions sorted out, you should be able to read/write/delete anything in the folders involved.
    Last edited by IGeeky1; Oct 24th, 2012 at 01:14 PM. Reason: Adding line

  12. #12
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    It's a copy process.

    More info...

    When the script initially creates the zip file, it has all the permissions that a normal file would have if you just right-clicked on windows explorer and created a new file. However, after the file transfer step has bombed, the zip file has lost all it's permissions - no users or groups have permission to access it.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  13. #13
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,789

    Re: VBScript errors with 'Access is Denied'

    just for gits and shiggles... what happens if you do it manually yourself? create the file by right clicking... then adding files... is it a particular file? it just sounds like a really weird thing going on.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  14. #14
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    Yep, it happens when I try to do it manually also.

    So let me try one file at a time and see what that does.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  15. #15
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    So, it doesn't seem to matter what file I choose to add to the zip file, or where I get the file from that I add to the zip file, or what directory the zip file is created in. Anywhere I create a zip file on my system and try to add files to it, I get the 'Access is Denied' error and the zip file looses its permissions. But once I go to the Properties | Security tab for the zip file and add 'Administrators' to the groups and give them full control over the zip file, then I can add files without any problem.

    so it sounds like some kind of system setting on my machine - maybe???
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


  16. #16
    Fanatic Member dolot's Avatar
    Join Date
    Nov 07
    Location
    Foothills of northeast Ga.
    Posts
    758

    Re: VBScript errors with 'Access is Denied'

    Well, I ended up having to do a format and re-install and that fixed it.

    Thanks everyone for the tips to try to help.
    I always add to the reputation of those who help me - when the system will allow it.
    My war with a browser-redirect trojan


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •