Q:

Access for delete files through a batch file is denied at windows 7

I am writing a batch file to clean some trashes files for my personal computer. Also I have checked the security option in properties, the batch file has full permission.
@echo off
echo running......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo done!
echo. & pause

I keep getting message that access is denied. Is that because the batch file is not launched as system administrator? Is anyway to resolve the issue?

A:

I think this is permission based. Try running the batch file as admin.
If that doesn't work you may have to reassign the permissions on the files, as some may be in protected folders.
To reassign permissions look at cacls, icacls and takeown.

