+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, batch file comman in Coding and Web Development; Hello, we have a set of user home folders that have been migrated from our old domain to our new ...
  1. #1

    Join Date
    Aug 2008
    Location
    Surrey
    Posts
    2
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Exclamation batch file comman

    Hello,
    we have a set of user home folders that have been migrated from our old domain to our new domain and they have broken ACLs. I know how to use cacls commands but the %username% parameter needs to match the foldername. how do I parse the folder name and use it as the username to match the user to the folder?
    Pleae help.
    racking brains and brains failing!!
    Jussy65

  2. #2
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,196
    Thank Post
    392
    Thanked 278 Times in 239 Posts
    Rep Power
    74
    Well you could script it (i have one at work i can provide) or you could use the free NTFSFix

    WiseSoft - NTFSFix. NTFS Permissions Utility.
    Last edited by cookie_monster; 12th August 2008 at 08:50 PM.

  3. #3

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144
    I found this VB script, but I havn't personally tested it, so use it with caution. It seems to do what you want, as long as the username is exactly the same as the folder name you're changing.

    You can change the CACLS command line to totally replace the ACL if your ACLs are totally broken, follow the help attached to the CACLS program to find out what switches you need to change. You will also need to add in the other users you want to have access e.g adminstrator to the end of the CACLS line if you do this. Running it in its current form edits the ACL and adds in the necessary permissions for the matching user only.

    Code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strPath = "\\Server\HomefolerPath"  '<--- Homefolder UNC path
    Set objFolder = objFSO.GetFolder(strPath)
    Set colSubfolders = objFolder.Subfolders
    For Each objSubfolder in colSubfolders
             strFolderName = objSubFolder.Name
             Set objShell = CreateObject("Wscript.Shell")
             strExec = objShell.Run("%COMSPEC% /c Echo Y| cacls " _
                       & strFolderName & " /E /T /P " & strFolderName & ":F ", 2, True)  '<--- 1st "strFolderName" reflects the homefolder name. 2nd "strFolderName" reflects Username
             If strExec <> 0 Then
                MsgBox "Error with " & strFolderName & " and folder: " & strFolderName
             End If
    Next
    If running it on the server, which I would recommend you do, and not from a workstation across the network, change from using the UNC path to the local path insted.

    hope that's of help.

    Mike.

  4. #4

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,708
    Thank Post
    3,244
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364

    spot on

    Quote Originally Posted by cookie_monster View Post
    Well you could script it (i have one at work i can provide) or you could use the free NTFSFix

    WiseSoft - NTFSFix. NTFS Permissions Utility.
    I was just about to suggest this and realised you had already - anyway just wanted to add a side note and mention that registration is free and then you can get to the downloads ( which are obviously free as well ) afaik ( at least they were last time I checked )

    very handy utils on that site as well ( password changer, ntfs fixer ) and possibly some other ones.

SHARE:
+ Post New Thread

Similar Threads

  1. Default Printer Batch File
    By karldenton in forum Windows
    Replies: 13
    Last Post: 23rd March 2010, 05:16 PM
  2. Pass in batch file
    By meastaugh1 in forum Windows
    Replies: 2
    Last Post: 17th January 2008, 08:02 PM
  3. Rename a PC from a batch file - Any ideas?
    By MrLudwig in forum Windows
    Replies: 13
    Last Post: 8th December 2007, 02:40 AM
  4. batch file to shutdown PCs
    By macca in forum Windows
    Replies: 5
    Last Post: 3rd May 2007, 09:20 AM
  5. batch file help
    By beeswax in forum Scripts
    Replies: 9
    Last Post: 3rd March 2006, 07:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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