title: changing owner of subfolders using icacls in a vbscript
body: <p>I have a network with over 700 users and I want to create a script that could change the owner of the home folders to domain admins and the sub-folders to the users themselves.</p>
  
  <p>This is what I could create with the help of my colleges, but this doesn't work for some reason. Can anyone help me please. Thanks.</p>
  
  <pre><code>Set objFSO  = CreateObject("Scripting.FileSystemObject")
  
  Set objFile = objFSO.OpenTextFile("G:\Userhome\userdirlist.txt", 1)
  
  Set oShell  = WScript.CreateObject("WSCript.shell")
  
  Do Until objFile.AtEndOfStream
  
      struserfolder = objFile.ReadLine
  
      oshell.run ("icacls G:\userhome\"+ struserfolder +"\*.*  /setowner domainname\" + "struserfolder" + " /t")
      oshell.run ("icacls G:\userhome\"+ struserfolder +"\*.*  /setowner domainname\Domain Admins")
  Loop
  </code></pre>