Results 1 to 29 of 29

Thread: Code to copy a folder

Hybrid View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    16

    Re: Code to copy a folder

    Thanks Hack that works a charm, I now i pushing it but how would I change the folder security to give users write and modify access to the folder?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Code to copy a folder

    VB Code:
    1. SetAttr "c:\myfolder\", vbNormal

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    16

    Re: Code to copy a folder

    I have tried the above but the user folder permissions are still read only [we only give users read access to the C:\ we setup folders with write and modify if it is needed] any help will be appriciated.

    In DOS you can change the CACLS on a folder:

    source = c:\myfolder

    cacls source /t /e /g users:c

    would using the shell command be the best way around this? and how would I do this [I am new to VB]

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Code to copy a folder

    SetAttr has always worked for me. How are you using it?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    16

    Re: Code to copy a folder

    I just added it to the end of your code tike this:

    Private Sub cmdMakeItHappen_Click()
    Dim fso As FileSystemObject
    Dim target_folder As Folder
    Dim Source = c:\myfolder
    Set fso = New FileSystemObject
    fso.CopyFolder "H:\MyFolder\", Source
    MsgBox "I am done"
    SetAttr Source, vbNormal

    End Sub

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Code to copy a folder

    You are getting a little ahead of yourself.

    Modify your code ever so slightly as follows:
    VB Code:
    1. 'not
    2. Dim Source = c:\myfolder
    3. 'but
    4. Dim Source As String
    5. Source = "C:\myfolder"
    Then try it.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    16

    Re: Code to copy a folder

    Its still not working, where does SetAttr Source, vbNormal get its permissons from? if it looks at the root directory in this case [C:\] then it will keep them as read only. I am not permitted to alter the permission of the directory as a whole only folders which need write and modify can be changed [the domain admins stop me from doing this]

Posting Permissions

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



Click Here to Expand Forum to Full Width