@echo off set IMAGE=c:\TEMP\IMAGE echo exporting PACKAGES list BEFORE doing any changes ... dism /Image:%IMAGE% /Get-Packages 1>Packages-BEFORE.txt FOR /F %%P in (packages-to-remove.csv) do ( echo removing package [ %%P ] dism /Image:%IMAGE% /Remove-Package /PackageName:"%%P" ) echo exporting remaining PACKAGES list ... dism /Image:%IMAGE% /Get-Packages 1>Packages-AFTER.txt rem showing packages ... dir Packages*.txt