r/PowerShell • u/Independent_Grab_242 • Dec 04 '22
How do I delete the old windows folder?
square support bow knee combative noxious squealing close deliver resolute
This post was mass deleted and anonymized with Redact
8
u/si1ic0n_gh0st Dec 04 '22
I use the following. You might have to re-run the commands a few times but after two or three iterations it should delete.
takeown /F c:\Windows.old\* /R /A /D Y > nul
echo Y| cacls c:\Windows.old\*.* /T /grant administrators:F > nul
rmdir /S /Q c:\Windows.old-9
u/Independent_Grab_242 Dec 04 '22 edited Jun 29 '24
heavy wild fly rock chase detail hurry aspiring deliver terrific
This post was mass deleted and anonymized with Redact
12
u/konikpk Dec 04 '22
You know this is not powershell right?
-3
u/Independent_Grab_242 Dec 04 '22 edited Jun 29 '24
rainstorm rustic liquid abounding soup husky pet toothbrush screw deer
This post was mass deleted and anonymized with Redact
2
2
2
u/AussieTerror Dec 04 '22
-6
u/Independent_Grab_242 Dec 04 '22 edited Jun 29 '24
cagey wakeful historical drab truck squash office roll deranged hard-to-find
This post was mass deleted and anonymized with Redact
5
u/lemonravens Dec 04 '22
I did this when I encountered permission issue as a local admin
How to Delete the Windows. old Folder Go to the Windows search bar. ... Type Cleanup. Launch the Disk Cleanup app. Click the “Clean up system files” button. ... If you have multiple drives, select the (C:) ... Check the box for “Previous Windows Installation(s)
1
2
u/Trakeen Dec 04 '22
You may not want to do this since windows can leave active drivers in that folder after an upgrade. You should be fine to remove anything else
Another tip is you can always go into windows recovery mode or a bootable linux install to remove in use files that won’t unload
1
u/HistoricalMove7954 Dec 23 '25
Salut tous!
Ai eu ce soucis de suppression du c:\windows en changeant de disque dur tout en voulant garder le contenu du disque... mon c:\windows devenait D:\windows2, et un bordel monstre pour le virer ! Que de temps et différentes méthodes testées sans succès !
Et enfin... le Graal... en cmd admin (touche windows + x, invite de commandes (admin)
takeown /F "C:\Windows2" /A /R /D O
icacls "C:\Windows2" /grant *S-1-5-32-544:F /T /C /Q
RD /S /Q "C:\Windows2"
ET HOP ! Plus de c:\windows2 !!!!!
Bonnes fêtes à toutes et tous ! Yôp !
2
u/Possible-Comment-804 Mar 10 '26
Muito obrigado, meu jovem!!!
Só uma coisa, fiz um mix da sua solução com a do u/si1ic0n_gh0st porque no Windows 11 no takeown o valor 'O' não é permitido para a opção '/D'
takeown /F "G:\Windows\*" /R /A /D Y > nul icacls "G:\Windows" /grant *S-1-5-32-544:F /T /C /Q RD /S /Q "G:\Windows"1
1
1
-1
u/deathbypastry Dec 04 '22
The problem is 3 fold
You have to take ownership of the file... You have to apply permissions to files and folders recursively You have to delete the files.
PS sucks (compared to other windows based toolsets) in managing file based permission in this sense. I spent a lot of time trying to leverage powershell to do this specific thing and it just didn't really work out.
Either the machine had a different PS VERSION, .net was down level. When it did work then operation was REALLY EXPENSIVE on CPU and DISK. It s a pain and just not worth it.
Use Takedown & icalcs commands, the remove them.
21
u/xCharg Dec 04 '22
What does it have to do with powershell?
Anyways run
cleanmgr.exeas administrator (it'll take some time to scan), from there select whatever takes couple dozen GB of space and start - process takes a lot of time, like maybe an hour. However it may not work if you've messed up ownership and permissions of that folder.