Here is the script that I am using.
It works for me in a testing environment.
Any input or suggestions is helpful.
I am not a programmer by any means, but can Google pretty well =D
We now have windows 7 and our current bat script is not working due to the fact the Vista and 7 tag a .V2 at the end of the folder name. The folder name is the user name (shortname).
Users have roaming profiles, so the script will be running on the server that contains the data.
'********************************************************************************************
' Resetting home profile permissions.
' Modifed by Jeffro with help from Joe S, Keith S, Google and credit to Ric Charlton's post:
' '********************************************************************************************
'
'********************************************************************************************
' Setting the Parameters
'********************************************************************************************
'
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ObjShell = Wscript.CreateObject("Wscript.Shell")
'
'********************************************************************************************
' Set the folder path "(ShowSubfolders FSO.GetFolder("OMG CHANGE ME")
'********************************************************************************************
'
ShowSubfolders FSO.GetFolder("E:\home-profiles")
'
'********************************************************************************************
' Run the sub command to Reset permissions based on home folder name.
' If userName contains a .V2 replace it with "" nothing.
' Added ,,True to wait for each CMD to finish before the next one starts.
'********************************************************************************************
'
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
userName = Replace(SubFolder.Name,".V2","")
CMDLine1 = "takeown /f """ & Subfolder & """ /r /d y"
CMDLine2 = "icacls.exe """ & Subfolder & """ /reset /T"
CMDLine3 = "icacls.exe """ & Subfolder & """ /grant:r ELKRIVER\" & userName & "OI)(CI)F"
CMDLine4 = "icacls.exe """ & Subfolder & """ /setowner ELKRIVER\" & userName & " /T"
ObjShell.Run CMDLine1,,True
ObjShell.Run CMDLine2,,True
ObjShell.Run CMDLine3,,True
ObjShell.Run CMDLine4,,True
Next
End Sub
'
'********************************************************************************************
' quit the script
'********************************************************************************************
'
Wscript.quit
It works for me in a testing environment.
Any input or suggestions is helpful.
I am not a programmer by any means, but can Google pretty well =D
We now have windows 7 and our current bat script is not working due to the fact the Vista and 7 tag a .V2 at the end of the folder name. The folder name is the user name (shortname).
Users have roaming profiles, so the script will be running on the server that contains the data.
'********************************************************************************************
' Resetting home profile permissions.
' Modifed by Jeffro with help from Joe S, Keith S, Google and credit to Ric Charlton's post:
' '********************************************************************************************
'
'********************************************************************************************
' Setting the Parameters
'********************************************************************************************
'
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ObjShell = Wscript.CreateObject("Wscript.Shell")
'
'********************************************************************************************
' Set the folder path "(ShowSubfolders FSO.GetFolder("OMG CHANGE ME")
'********************************************************************************************
'
ShowSubfolders FSO.GetFolder("E:\home-profiles")
'
'********************************************************************************************
' Run the sub command to Reset permissions based on home folder name.
' If userName contains a .V2 replace it with "" nothing.
' Added ,,True to wait for each CMD to finish before the next one starts.
'********************************************************************************************
'
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
userName = Replace(SubFolder.Name,".V2","")
CMDLine1 = "takeown /f """ & Subfolder & """ /r /d y"
CMDLine2 = "icacls.exe """ & Subfolder & """ /reset /T"
CMDLine3 = "icacls.exe """ & Subfolder & """ /grant:r ELKRIVER\" & userName & "OI)(CI)F"
CMDLine4 = "icacls.exe """ & Subfolder & """ /setowner ELKRIVER\" & userName & " /T"
ObjShell.Run CMDLine1,,True
ObjShell.Run CMDLine2,,True
ObjShell.Run CMDLine3,,True
ObjShell.Run CMDLine4,,True
Next
End Sub
'
'********************************************************************************************
' quit the script
'********************************************************************************************
'
Wscript.quit