mecivic Posted October 28, 2011 Share Posted October 28, 2011 HiI am running Windows 7 64bitI am having problems creating a batch code to delete files in folders.rd C:\Users\Brian\AppData\Local\Temp /s /q md C:\Users\Brian\AppData\Local\TempThe code above works and removes the files, but I can't remove anything in this path below.rd C:\Windows\Help\Help\en-US /s /qmd C:\Windows\Help\Help\en-USCan anyone explain why it don't work.I am creating a project to remove all the rubbish I don't use with windows, what I do when I reinstall windows I manually remove what I don't use so I want to create batch files to do it for me. Link to comment Share on other sites More sharing options...
IcemanND Posted October 29, 2011 Share Posted October 29, 2011 Because that folder has special permissions set on it and no assigned user has rights to delete it. You would have to change the permissions on the folder and files using CALCS first. Link to comment Share on other sites More sharing options...
theeXeic Posted October 31, 2011 Share Posted October 31, 2011 You should use icacls because cacls is now deprecated. Link to comment Share on other sites More sharing options...
allen2 Posted October 31, 2011 Share Posted October 31, 2011 you might also need to use takeown before icacls. Link to comment Share on other sites More sharing options...
mecivic Posted November 10, 2011 Author Share Posted November 10, 2011 (edited) HiI am having problems here, I am trying to delete files and folders with windows 7 64bitI have tried takeowner and also tried icaclsCan anyone help please i am getting messed up.The code below is what i have tried + other attempts with no luck[code@echo offtakeown /f C:\Windows\System32\en-US\winload.exe.muicacls C:\Windows\System32\en-US\winload.exe.mui /Brian:cDelTree("C:\Windows\Help\Help\en-US", nil);Folder.DeleteTree("C:\Windows\Help\Help\en-US", nil);] Edited November 10, 2011 by mecivic Link to comment Share on other sites More sharing options...
IcemanND Posted November 10, 2011 Share Posted November 10, 2011 icalcs c:\windows\system32\en-us\winload.exe.mui /grant Brian:FI believe you will need to at least grant yourself permission on the Help folder if not take ownership on it and the contents first. Link to comment Share on other sites More sharing options...
mecivic Posted November 11, 2011 Author Share Posted November 11, 2011 This is confusing me.I changed the code around and still dont work.Can anyone explaine what i am doing wrong.@echo officalcs c:\windows\system32\en-us\winload.exe.mui /grant Brian:Ftakeown /f C:\Windows\System32\en-US\winload.exe.muiDelTree("C:\Windows\Help\Help\en-US", nil);Folder.DeleteTree("C:\Windows\Help\Help\en-US", nil);I have also added a folder Testing-1 and Testing-2 inside like this C:\Windows\Testing1\Testing2 and still cant figure it out to delete those.Can someone explaine how to do it in Windows 7 64bit Link to comment Share on other sites More sharing options...
IcemanND Posted November 11, 2011 Share Posted November 11, 2011 @echo officalcs c:\windows\system32\en-us\winload.exe.mui /grant Brian:Ftakeown /f C:\Windows\System32\en-US\winload.exe.muiDelTree("C:\Windows\Help\Help\en-US", nil);Folder.DeleteTree("C:\Windows\Help\Help\en-US", nil);Not sure where you are coming up with Deltree or Folder.deltree, neither are valid in a command in a CMD/BAT script. To delete a folder and the tree under it:rd /s /q <Root path>so to get rid of en-us:rd /s /q C:\windows\help\help\en-usand your icalcs and takeown command are not taking ownership of the help folder. It is taking ownership of a single file, winload.exe which won't help you with deleting the help folder, you need to point it at the folder you are trying to delete. Link to comment Share on other sites More sharing options...
mecivic Posted November 12, 2011 Author Share Posted November 12, 2011 Sorry about this but still can't get it rightThis is what i have now and still don't work.@Echo Officalcs C:\Windows\Help\Help\en-US /grant Brian:Ftakeown /f C:\Windows\Help\Help\en-USrd /s /q C:\Windows\Help\Help\en-USWhat i want to do is delete the en-US folder and it's contents inside.The code above, is that correct. Link to comment Share on other sites More sharing options...
allen2 Posted November 12, 2011 Share Posted November 12, 2011 The takeown command should be run before the icacls one. Link to comment Share on other sites More sharing options...
mecivic Posted November 12, 2011 Author Share Posted November 12, 2011 Still don't work@Echo Offtakeown /f C:\Windows\Help\Help\en-USicalcs C:\Windows\Help\Help\en-US /grant Brian:Frd /s /q C:\Windows\Help\Help\en-US Link to comment Share on other sites More sharing options...
allen2 Posted November 12, 2011 Share Posted November 12, 2011 (edited) Is icaLCs a new command or a mistake ? The right one is icaCLs. Edited November 12, 2011 by allen2 Link to comment Share on other sites More sharing options...
IcemanND Posted November 12, 2011 Share Posted November 12, 2011 sorry, my typo.need to add the switches for recursive also.takeown /r /f en-USicacls en-US /grant brian:F /t Link to comment Share on other sites More sharing options...
mecivic Posted November 12, 2011 Author Share Posted November 12, 2011 Thanks for your patience with me.This is the code i have now.takeown /r /f en-USicacls en-US /grant Brian:F /t rd /s /q C:\Windows\Help\Help\en-USI have saved it as testing.batThis is what it's coming up withI have also added a folder to the same Help File as C:\Windows\Help\Help\Deleteand used the code takeown /r /f Deleteicacls Delete /grant Brian:F /t rd /s /q C:\Windows\Help\Help\DeleteAnd the same error Link to comment Share on other sites More sharing options...
myselfidem Posted November 12, 2011 Share Posted November 12, 2011 You can try like this:@echo offcmd /c TAKEOWN /F "%systemdrive%\Windows\Help\Help\fr-FR" /R /D O && ICACLS "%systemdrive%\Windows\Help\Help\fr-FR" /grant:r *S-1-5-32-544:F /Trmdir /s /q "%systemdrive%\Windows\Help\Help\fr-FR"exitFor english version: @echo offcmd /c TAKEOWN /F "%systemdrive%\Windows\Help\Help\en-US" /R /D Y && ICACLS "%systemdrive%\Windows\Help\Help\en-US" /grant:r *S-1-5-32-544:F /Trmdir /s /q "%systemdrive%\Windows\Help\Help\en-US"exitWorks fine for me! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now