FileSystemObject.CopyFile: Permission Denied - ADO DAO RDO RDS

This is a discussion on FileSystemObject.CopyFile: Permission Denied - ADO DAO RDO RDS ; MS Access 2003, running on Vista Ultimate sp1 I'm trying to simply copy a file from one location to another, and get a runtime error 70: Permission Denied. The permissions for the file are set for full control for all ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

FileSystemObject.CopyFile: Permission Denied

  1. Default FileSystemObject.CopyFile: Permission Denied

    MS Access 2003, running on Vista Ultimate sp1

    I'm trying to simply copy a file from one location to another, and get a
    runtime error 70: Permission Denied. The permissions for the file are set for
    full control for all users.

    Here is the sub:

    Public Sub CopyFile()

    Dim fs As Object
    Dim isthere As Boolean

    Set fs = CreateObject("Scripting.FileSystemObject")
    isthere = fs.FileExists("c:\Database\Accounting\UpdateAssetMaster.bat")

    If isthere = True Then

    fs.CopyFile "c:\Database\Accounting\UpdateAssetMaster.bat",
    "c:\database"

    End If

    End Sub

    I can't seem to get this to work, any suggestions would be appreciated.

  2. Default Re: FileSystemObject.CopyFile: Permission Denied

    "TomT" <tomt@newsgroup.nospam> wrote in message
    news:3AE023E1-5131-46F1-94B6-B0285717F7A6@microsoft.com...
    > MS Access 2003, running on Vista Ultimate sp1
    >
    > I'm trying to simply copy a file from one location to another, and get a
    > runtime error 70: Permission Denied. The permissions for the file are set
    > for
    > full control for all users.
    >
    > Here is the sub:
    >
    > Public Sub CopyFile()
    >
    > Dim fs As Object
    > Dim isthere As Boolean
    >
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > isthere = fs.FileExists("c:\Database\Accounting\UpdateAssetMaster.bat")
    >
    > If isthere = True Then
    >
    > fs.CopyFile "c:\Database\Accounting\UpdateAssetMaster.bat",
    > "c:\database"
    >
    > End If
    >
    > End Sub
    >
    > I can't seem to get this to work, any suggestions would be appreciated.



    Do you have write permissions on the C:\Database folder?

    --
    Dirk Goldgar, MS Access MVP
    www.datagnostics.com

    (please reply to the newsgroup)


  3. Default Re: FileSystemObject.CopyFile: Permission Denied

    TomT <tomt@newsgroup.nospam> wrote:

    > MS Access 2003, running on Vista Ultimate sp1
    >
    > I'm trying to simply copy a file from one location to another, and get a
    > runtime error 70: Permission Denied. The permissions for the file are set for
    > full control for all users.
    >

    [...]>
    > fs.CopyFile "c:\Database\Accounting\UpdateAssetMaster.bat",
    > "c:\database"

    [...]

    I have had similar problems in Vista SP1 with the VBA FileCopy
    statement.

    I now use an API call:

    Public Declare Function CopyFile Lib "Kernel32" Alias "CopyFileA" _
    (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, _
    ByVal bFailIfExists As Long) As Long

    Call CopyFile("C:\Old\myfile.bat", "C:\New\Myfile.bat", False)

    This works for me without the permission error.
    Notice that CopyFile returns 0 *in case of an error*, so I actually
    use something like

    If CopyFile(...) <> 0 Then
    ... ok
    Else
    Call MsgBox("CopyFile failed")
    End If

    HTH
    Matthias Kläy
    --
    www.kcc.ch

  4. Default RE: FileSystemObject.CopyFile: Permission Denied

    Hello,

    You may also want to run as administrator to test the stiatuion, right
    click on the icon, select Properties -> Compatibility and enable the “Run
    this program as an administrator”
    checkbox. Click on Apply and then Ok.

    Best Regards,

    Peter Yang
    MCSE2000/2003, MCSA, MCDBA
    Microsoft Online Partner Support


    =====================================================

    When responding to posts, please "Reply to Group" via your
    newsreader so that others may learn and benefit from this issue.
    ======================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.


  5. Default Re: FileSystemObject.CopyFile: Permission Denied

    Yes, full permissions

    "Dirk Goldgar" wrote:

    > "TomT" <tomt@newsgroup.nospam> wrote in message
    > news:3AE023E1-5131-46F1-94B6-B0285717F7A6@microsoft.com...
    > > MS Access 2003, running on Vista Ultimate sp1
    > >
    > > I'm trying to simply copy a file from one location to another, and get a
    > > runtime error 70: Permission Denied. The permissions for the file are set
    > > for
    > > full control for all users.
    > >
    > > Here is the sub:
    > >
    > > Public Sub CopyFile()
    > >
    > > Dim fs As Object
    > > Dim isthere As Boolean
    > >
    > > Set fs = CreateObject("Scripting.FileSystemObject")
    > > isthere = fs.FileExists("c:\Database\Accounting\UpdateAssetMaster.bat")
    > >
    > > If isthere = True Then
    > >
    > > fs.CopyFile "c:\Database\Accounting\UpdateAssetMaster.bat",
    > > "c:\database"
    > >
    > > End If
    > >
    > > End Sub
    > >
    > > I can't seem to get this to work, any suggestions would be appreciated.

    >
    >
    > Do you have write permissions on the C:\Database folder?
    >
    > --
    > Dirk Goldgar, MS Access MVP
    > www.datagnostics.com
    >
    > (please reply to the newsgroup)
    >


  6. Default Re: FileSystemObject.CopyFile: Permission Denied

    Thanks Matthias - I had a feeling it was Vista related. I'm going to run a
    test on a different OS.

    "Matthias Klaey" wrote:

    > TomT <tomt@newsgroup.nospam> wrote:
    >
    > > MS Access 2003, running on Vista Ultimate sp1
    > >
    > > I'm trying to simply copy a file from one location to another, and get a
    > > runtime error 70: Permission Denied. The permissions for the file are set for
    > > full control for all users.
    > >

    > [...]>
    > > fs.CopyFile "c:\Database\Accounting\UpdateAssetMaster.bat",
    > > "c:\database"

    > [...]
    >
    > I have had similar problems in Vista SP1 with the VBA FileCopy
    > statement.
    >
    > I now use an API call:
    >
    > Public Declare Function CopyFile Lib "Kernel32" Alias "CopyFileA" _
    > (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, _
    > ByVal bFailIfExists As Long) As Long
    >
    > Call CopyFile("C:\Old\myfile.bat", "C:\New\Myfile.bat", False)
    >
    > This works for me without the permission error.
    > Notice that CopyFile returns 0 *in case of an error*, so I actually
    > use something like
    >
    > If CopyFile(...) <> 0 Then
    > ... ok
    > Else
    > Call MsgBox("CopyFile failed")
    > End If
    >
    > HTH
    > Matthias Kläy
    > --
    > www.kcc.ch
    >


  7. Default RE: FileSystemObject.CopyFile: Permission Denied

    Peter, I ran msaccess.exe as administrator, but still got the same error

    ""Peter Yang[MSFT]"" wrote:

    > Hello,
    >
    > You may also want to run as administrator to test the stiatuion, right
    > click on the icon, select Properties -> Compatibility and enable the “Run
    > this program as an administrator”
    > checkbox. Click on Apply and then Ok.
    >
    > Best Regards,
    >
    > Peter Yang
    > MCSE2000/2003, MCSA, MCDBA
    > Microsoft Online Partner Support
    >
    >
    > =====================================================
    >
    > When responding to posts, please "Reply to Group" via your
    > newsreader so that others may learn and benefit from this issue.
    > ======================================================
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >


  8. Default RE: FileSystemObject.CopyFile: Permission Denied

    Hello,

    Please check if the issue occurs if the destination folder is empty or a
    new folder? You may want to check if you encounter the following known
    issue:

    941190 Permission Denied error returned when FileSystemObject.CopyFolder
    encounters a Read-Only Destination File
    http://support.microsoft.com/default...b;EN-US;941190

    Best Regards,

    Peter Yang
    MCSE2000/2003, MCSA, MCDBA
    Microsoft Online Partner Support


    =====================================================

    When responding to posts, please "Reply to Group" via your
    newsreader so that others may learn and benefit from this issue.
    ======================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.


  9. Default RE: FileSystemObject.CopyFile: Permission Denied

    I created a new folder, test. It's read only flag is set, and tho I can
    un=check it, it doesn't stick. I have full permissions on the folder. I tried
    the following via a command prompt:

    attrib -r +s c:\test

    It did not appear to make any difference. The process still fails to copy a
    file, with the same error.

    Thanks

    ""Peter Yang[MSFT]"" wrote:

    > Hello,
    >
    > Please check if the issue occurs if the destination folder is empty or a
    > new folder? You may want to check if you encounter the following known
    > issue:
    >
    > 941190 Permission Denied error returned when FileSystemObject.CopyFolder
    > encounters a Read-Only Destination File
    > http://support.microsoft.com/default...b;EN-US;941190
    >
    > Best Regards,
    >
    > Peter Yang
    > MCSE2000/2003, MCSA, MCDBA
    > Microsoft Online Partner Support
    >
    >
    > =====================================================
    >
    > When responding to posts, please "Reply to Group" via your
    > newsreader so that others may learn and benefit from this issue.
    > ======================================================
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >


  10. Default RE: FileSystemObject.CopyFile: Permission Denied

    Hello,

    Based on my test, this issue occurs because the destination file name is
    not completed. Please try the following code to see if it works for you:

    Public Sub CopyFile()

    Dim fs As Object
    Dim isthere As Boolean

    Set fs = CreateObject("Scripting.FileSystemObject")
    isthere = fs.FileExists("c:\Database\Accounting\UpdateAssetMaster.bat")

    If isthere = True Then

    fs.CopyFile "c:\Database\Accounting\UpdateAssetMaster.bat",
    "c:\database\UpdateAssetMaster.bat"

    End If

    End Sub

    If you encounter any problem, please feel free to let's know. Thank you.

    Best Regards,

    Peter Yang
    MCSE2000/2003, MCSA, MCDBA
    Microsoft Online Partner Support


    =====================================================

    When responding to posts, please "Reply to Group" via your
    newsreader so that others may learn and benefit from this issue.
    ======================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.


+ Reply to Thread
Page 1 of 2 1 2 LastLast