Menu Close

Cleaning up the Windows “System Reserved Partition” for my 20H2 Script

“60% of the time it works 100% of the time”

I manage some labs with a few colleagues across the country. We need to update Windows from time to time with the feature updates. I had a pretty solid run with the machines I manage and image, but they had larger drives than some of the other labs out and about. The issue seemed to be that the System Reserved Partition was “too full” and needed space. There were a few options to do this, like resizing the partition, but that didn’t sound fun. So, I opted for a method of clearing out the fonts, and wrote a script to do it.

<Insert Relevant XKCD here>

The batch script:

echo Select DISK 0 >> 20h2_update_diskpart_CMD_p1.txt
echo Select VOLUME 0 >> 20h2_update_diskpart_CMD_p1.txt
echo assign letter=M >> 20h2_update_diskpart_CMD_p1.txt

echo Select DISK 0 >> 20h2_update_diskpart_CMD_p2.txt
echo Select VOLUME 0 >> 20h2_update_diskpart_CMD_p2.txt
echo Remove letter=M >> 20h2_update_diskpart_CMD_p2.txt

diskpart /s 20h2_update_diskpart_CMD_p1.txt


M:
cd Boot\Fonts
takeown /d y /r /f .
icacls M:\* /save %systemdrive%\NTFSp.txt /c /t
icacls . /grant %username%:F /t
del *.* /f
icacls M:\ /restore %systemdrive%\NTFSp.txt /c /t



diskpart /s 20h2_update_diskpart_CMD_p2.txt

del 20h2_update_diskpart_CMD_p1.txt /f
del 20h2_update_diskpart_CMD_p2.txt /f

shutdown -r -t 60