Tuesday 27 January 2015

Command line to remove or move user roaming profile with Server 2012

The following two commands let you firstly take ownership of all the files in the specified folder and then grant full access to the files to the administrators group.
takeown /f /r /d y icacls /grant administrators:F /T
You can also use the following script (credit to: http://WinHelpOnline.com ):
Windows Registry Editor Version 5.00 ;Adds Take Ownership command to the context menu in Vista or Win 7 ;Also provides "Administrators" group with Full Control permissions. [-HKEY_CLASSES_ROOT\*\shell\runas] [HKEY_CLASSES_ROOT\*\shell\runas] @="Take Ownership" "Extended"="" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\*\shell\runas\command] @="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F" [-HKEY_CLASSES_ROOT\Directory\shell\runas] [HKEY_CLASSES_ROOT\Directory\shell\runas] @="Take Ownership" "Extended"="" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\Directory\shell\runas\command] @="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
Simply save it with a ".reg" file extension. You should then be able to right click a folder WHILE holding down shift and selecting "Take Ownership."

0 comments:

Post a Comment