$ErrorActionPreference = "stop" function reallyDelete($d) { function renameToNumbersRecursive($dir) { $i = 0 foreach($f in (dir $dir)) { while(Test-Path ($dir + "\" + $i)) { $i++ } try { Rename-Item $f.FullName ($dir + "\" + $i) } catch { takeown /f $dir | Out-Null icacls $dir /reset | Out-Null takeown /f $f.FullName | Out-Null icacls $f.FullName /reset | Out-Null Rename-Item $f.FullName ($dir + "\" + $i) } } foreach($f in (dir $dir)) { if($f -is [System.IO.DirectoryInfo]) { renameToNumbersRecursive($f.FullName) } } } # paths might become too long for icacls, so rename paths to short numbers renameToNumbersRecursive $d takeown /f $d /r | Out-Null icacls $d /reset /T | Out-Null attrib -s -h -r "$d\*.*" /s /d | Out-Null cmd /c del /s /q $d | Out-Null cmd /c rmdir /s /q $d | Out-Null } reallyDelete "C:\ProgramData\Docker"
Wednesday, November 22, 2017
Delete the undeletable on Windows
I had trouble deleting C:\ProgramData\Docker on Docker for Windows using Windows containers. This is because it contains a full Windows directory layout, with all system files and special permissions and flags. Here's a Powershell snippet to get a file hierarchy on Windows into a state where it can be deleted.
Tuesday, May 30, 2017
Utility to remind you to keep a task diary
Here's a program that asks you every hour what you are doing, so you end up with a diary at the end of the day. It saves your input to a text file WhatAmIDoing.txt in the same folder you put the exe.
Note that if you move the location of the exe file, you will need to click the "ask every hour" button again.
https://acoby.com/utils/WhatAmIDoing.exe
Note that if you move the location of the exe file, you will need to click the "ask every hour" button again.
https://acoby.com/utils/WhatAmIDoing.exe
Subscribe to:
Posts (Atom)