+ Reply to Thread
Results 1 to 7 of 7
  1. Psychotron Member Megadeth4168's Avatar
    Join Date
    Jan 2006
    Location
    Detroit
    Posts
    2,162

    Certifications
    A+, Network+, Security+, Server+,Project+,MCSE, CCNA:S, CISSP, CCNP, CEH, GCED
    #1

    Default Anyone good with Visual Basic?

    I'm just starting out with VB so forgive any newbie questions.

    I have a simple program that copies a directory from a network drive to a directory on my local drive. Pretty simple, hardcoded file location.

    The problem is that the permissions to the folder are not retained. Is there a simple way of retaining the permissions when the file is copied?

    I'm sure I will have more questions as I keep working on learning this.
    Reply With Quote Quote  

  2. SS -->
  3. mikej412's caddy sprkymrk's Avatar
    Join Date
    Feb 2006
    Location
    Charleston, SC
    Posts
    4,976

    Certifications
    MCP (NT4 Server), MCSA 2000, MCSA 2003, CCNA, Security+, Network+
    #2
    I have found the best way is to call an external program like cacls.exe, xcacls or suninacle.exe from your vbscript. I never really got into vbscripting too much because the W2k, WXP and W2K3 shell commands and RK tools allow me to do everything the "old" way in batch/cmd scripting. Old dog - new tricks - you know...
    Reply With Quote Quote  

  4. Certification Invigilator Forum Admin JDMurray's Avatar
    Join Date
    Jul 2003
    Location
    Surf City USA
    Posts
    10,596
    Blog Entries
    50

    Certifications
    GSEC, EnCE, CISSP, SSCP, CEH (ANSI), CASP, CCNA, CCENT, CWSP, CWNA, CWTS, Security+, Server+, Network+, A+, DHTI+, PDI+, MSIT InfoSec
    #3
    By "Visual Basic" are you using VB6, VB.NET, or Visual Basic 2005?

    Assuming VB6, there are no intrinsic file copy procedures that preserve the file's attributes. It's common to add a reference to the FileSystemObject and use its Attributes property to read/set the file attributes before/after the file is copied. Even with VB in .NET I don't know of a method to perform a file copy which preserves the attributes. I think you'd still need to use File.GetAttributes(srcFileName) and File.SetAttributes(dstFileName).
    Moderator of the InfoSec, CWNP, IT Jobs, Virtualization, Java, and Microsoft Developers forums at www.techexams.net
    --
    Blog: www.techexams.net/blogs/jdmurray
    LinkedIn: www.linkedin.com/in/jamesdmurray
    Twitter: www.twitter.com/jdmurray
    Reply With Quote Quote  

  5. Psychotron Member Megadeth4168's Avatar
    Join Date
    Jan 2006
    Location
    Detroit
    Posts
    2,162

    Certifications
    A+, Network+, Security+, Server+,Project+,MCSE, CCNA:S, CISSP, CCNP, CEH, GCED
    #4
    Visual Basic 2005

    I will try File.GetAttributes(srcFileName) and File.SetAttributes(dstFileName).
    Thanks for the suggestion
    Reply With Quote Quote  

  6. Member
    Join Date
    Oct 2005
    Posts
    52

    Certifications
    DCSE, MCP, Network+, CCNA
    #5
    I've been there and done that. So I know what works perfect. I've tried to make an exact backup of a server using vbscript, had a script with 127 lines of code. Then I found a neato program in the Windows 2003 resource kit called Robocopy. It will do exactly what you need it to do in 5 lines or less in a batchfile.

    Check this out: http://www.ss64.com/nt/robocopy.html

    download it here: http://www.microsoft.com/downloads/d...displaylang=en

    Last program you'll ever use for this stuff

    PS: It does copy all ACL's with the /copyall switch read the first link!

    Hope this helps will save you LOTS OF TIME! TRUST ME I KNOW!
    Reply With Quote Quote  

  7. Senior Member
    Join Date
    Jun 2006
    Location
    Tampa Bay
    Posts
    1,266

    Certifications
    MCSA 2000, MCSE 2003, Exchange 2000, CCNA, CCNA Security, CNE, A+, Network+, Security+
    #6
    Quote Originally Posted by Megadeth4168
    Visual Basic 2005

    I will try File.GetAttributes(srcFileName) and File.SetAttributes(dstFileName).
    Thanks for the suggestion
    Careful, attributes are not the same as ACLs.
    Reply With Quote Quote  

  8. Psychotron Member Megadeth4168's Avatar
    Join Date
    Jan 2006
    Location
    Detroit
    Posts
    2,162

    Certifications
    A+, Network+, Security+, Server+,Project+,MCSE, CCNA:S, CISSP, CCNP, CEH, GCED
    #7
    Looks good, I'll check it out
    Reply With Quote Quote  

+ Reply to Thread

Social Networking & Bookmarks