Home » Questions » Computers [ Ask a new question ]

What's the best way to convert this complex "takeown" command into a shutdown script?

What's the best way to convert this complex "takeown" command into a shutdown script?

I found this command here.

Asked by: Guest | Views: 327
Total answers/comments: 1
Guest [Entry]

"takown and icacls are DOS commands. As there is no path specified to reach them in the Registry file, I assume they are available on the path.
Just create a batch file (say ownandgrant.bat) containing
@echo off
takeown /f %1 /r /d y
icacls %1 /grant administrators:F /t

This could cause issues if the directory name contains 1 or more spaces so make sure you enclose the directory with double quotes when calling the batch file.
ownandgrant.bat ""my special directory"""