Here are some examples of using the takeown command:
takeown /f C:\Users\OldUser /r
The takeown command is a powerful Windows command-line utility that allows an administrator to recover access to a file or folder by becoming its owner. This is especially useful when a file's security permissions (ACLs) are corrupted or when a user account that previously owned the file has been deleted. ITPro Today +3 Core Command Syntax The basic syntax for the command is: how to use takeown command
takeown [/f] [/r] [/d] [/a] file
: Gives ownership to the Administrators group instead of the current user. Here are some examples of using the takeown