Loading ...
Sorry, an error occurred while loading the content.

Changing permissions in a BAT file

Expand Messages
  • Gary Kuznitz
    I need to delete these files: del C: Windows System32 DriverStore en-US hp*.* I m getting an error: Access is denied I ve tried running it a administrator
    Message 1 of 1 , Aug 29 9:27 AM
    • 0 Attachment
      I need to delete these files:

      del "C:\Windows\System32\DriverStore\en-US\hp*.*"

      I'm getting an error: Access is denied

      I've tried running it a administrator It gives the same error.

      I have found a script that will set the permissions so I can delete the files:

      set USERDIRS=C:\Windows\System32\DriverStore\en-US
      for /f "tokens=*" %%a in ('dir /ad /b ^"%USERDIRS%^"') do (
      takeown /R /A /F "%USERDIRS%\%%a" /D Y
      xcacls "%USERDIRS%\%%a" /T /E /P Administrators:F
      xcacls "%USERDIRS%\%%a" /T /E /P SYSTEM:F
      xcacls "%USERDIRS%\%%a" /T /E /P %%a:F
      subinacl.exe /noverbose /file "%USERDIRS%\%%a" /setowner=%%a
      subinacl.exe /noverbose /subdirectories "%USERDIRS%\%%a\*"
      /setowner=%%a
      )

      I'm not familiar enough with the commands to know if this script will work for the files
      I need deleted and only the files I need deleted. I have not tested the script.

      Could someone that knows these commands please make sure this script will affect the
      files I am working with and not other files on the system.

      Thank you,

      Gary Kuznitz
    Your message has been successfully submitted and would be delivered to recipients shortly.