I was trying this (very rudimentary) command in a batch file
takeown.exe /F c:\WINDOWS\SYSTEM32\%1%
ICACLS C:\WINDOWS\SYSTEM32\%1% /grant MY\PC:F
And when I run it from an admin CMD prompt as:
c:\Data>takeownscript.bat drivers\netbio.sys
It throws an error saying:
c:\Data>takeown.exe /F c:\WINDOWS\SYSTEM32\drivers\netio.sys
SUCCESS: The file (or folder): "c:\WINDOWS\SYSTEM32\drivers\netio.sys" now owned by user "MY\PC".
c:\Data>ICACLS C:\WINDOWS\SYSTEM32\drivers\netio.sysF C:\WINDOWS\SYSTEM32\drivers\netio.sysF: The system cannot find the file specified. Successfully processed 0 files; Failed processing 1 files
How/why is the F getting appended to the driver path ? I am suspecting that I am not using the correct replacement syntax.