VBSCRIPT: Moving a file, inheriting NTFS permissions

Posted on 2006-05-02
Last Modified: 2008-03-06
Hi,  Have a seemingly simple task but cannot seem to find the answer.

Have a Windows 2003 Server.  Need to move specific files on a regular basis from one folder to another on the same volume.  This is working ok now via asp script, but there is a quirky permissions problem.

By default, if a file is being moved from one folder to another and the source and destination folders are on the same volume, which they are, then the file will retain the original permissions.  I do not want that.  I need the file that is being moved to inherit the new permissions of the destination folder.

As a workaround i have made the permissions on the source and destination folder the same.  But this is undesirable.

Is there a way to force this programtically?

Thanks in advance.
Question by:MarkDJordan
    LVL 1

    Accepted Solution

    Call SetPermissions(path2File, "IUSR_machineName")

    Sub SetPermissions(strFileOrFolder, strUserName)
         dim objWSH
         set objWSH = CreateObject("WScript.Shell")
         Call objWSH.Run("cmd /c echo y| CACLS " & strFileOrFolder & " /t /g " & trim(strUserName) & ":f", 0, True)
         set objWSH = Nothing
    End Sub
    LVL 1

    Expert Comment

    just 175?

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now