[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 330
  • Last Modified:

VBSCRIPT: Moving a file, inheriting NTFS permissions

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.
  • 2
1 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
just 175?

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now