/build/static/layout/Breadcrumb_cap_w.png

VB Script to Change the permissions of a folder, copy contents of a folder and rename the folder

Guys,

I know you guys are too good at scripting. But for the newbies that are trying to learn something. Just in case, if they need something like this. This might be of little help.

VB Script to Change the permissions of a folder, copy contents of a folder and rename the folder

Dim objFSO

Dim objShell

Dim strSysDir

Dim Calcds

Dim FoldPerm

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objShell = CreateObject("WScript.Shell")

 

strSysDir = objFSO.GetSpecialFolder(1).Path

If Right(strSysDir,1) <> "\" Then strSysDir = strSysDir & "\"

Calcds = sSysDir & "cacls.exe"

 

FoldPerm = """" & Calcds &"""" & """RequiredFolderPath""" & "  /t /e /c /p " & """Users""" & ":F"

objShell.Run FoldPerm, 1, True

 

 

If objFSO.FolderExists("SOURCEPATH") Then

 

objFSO.CopyFolder "SOURCEPATH", "DESTINATIONPATH", True

End If

 

 

If objFSO.FolderExists("ORIGINALNAME") Then

 

objFSO.MoveFolder "ORIGINALNAME", "RENAMEDFOLDER"  

 

End If

 

WScript.Quit()

 

 

 

 

 


Comments

  • ...and not a single line of error-trapping anywhere. Still, we all know that everything always works 100% every time, don't we? :-) - anonymous_9363 10 years ago
  • Only if u say so. And I just posted this just coz i had trouble with CopyFolder. Dont really have to go back and look for it again. - Sidhugadu 10 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ