{"id":2653,"date":"2017-11-06T21:06:16","date_gmt":"2017-11-06T19:06:16","guid":{"rendered":"http:\/\/blog.hosebei.ch\/?p=2653"},"modified":"2017-11-06T21:06:16","modified_gmt":"2017-11-06T19:06:16","slug":"windows-10-remove-windows-old-folder","status":"publish","type":"post","link":"https:\/\/blog.hosebei.ch\/?p=2653","title":{"rendered":"Windows 10 &#8211; Remove Windows.old Folder"},"content":{"rendered":"<p>Long time no see, huh? Now I&#8217;m back with a new post about removing the Windows.old folder after a feature Upgrade.<br \/>\nRecently I seen this on twitter, a commented it with: Why don&#8217;t you let the automation from Windows 10 let it do. But since then, I was in a project, where the removal of this folder was required, and within the Upgrade Task Sequence. I thought, this is easy, starting the Scheduled Task should do the job&#8230;<br \/>\n<a href=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old.png?w=300\" alt=\"\" width=\"300\" height=\"161\" class=\"aligncenter size-medium wp-image-2654\" srcset=\"https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old.png 1329w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old-300x161.png 300w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old-1024x549.png 1024w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old-768x412.png 768w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><!--more--><\/p>\n<p>You can easily start this task within a command line, but since this does not solve the &#8220;problem&#8221;, I don&#8217;t provide this command. But I will provide a more useful information. You can use cleanmgr.exe, yes, this is the &#8220;Disk Cleanup&#8221; which is included since some versions of Windows:<br \/>\n<a href=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old02.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old02.png?w=248\" alt=\"\" width=\"248\" height=\"300\" class=\"aligncenter size-medium wp-image-2656\" srcset=\"https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old02.png 376w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old02-248x300.png 248w\" sizes=\"auto, (max-width: 248px) 100vw, 248px\" \/><\/a><\/p>\n<p>But this is a GUI, how can we use this within in TS? I used my prefered search engine, and found a solution. You can create a Cleanup Profile, save this to registry, and then run the profile from command line. Seem cool? Here are the steps:<br \/>\nGo ahead, and start cleanmgr.exe with the following parameters:<br \/>\n<code>cleanmgr.exe \/sageset:1703<\/code><br \/>\n<a href=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old031.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old031.png?w=300\" alt=\"\" width=\"300\" height=\"65\" class=\"aligncenter size-medium wp-image-2659\" srcset=\"https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old031.png 400w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old031-300x65.png 300w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nThe parameter sageset instructs the cleanup wizard to save the selected options to the registry. The following number after the parameter sets the profile ID, or number, with which the settings are stored. The Number can be from 0 to 65535, so there might be enough numbering possible.<\/p>\n<p>As soon as the wizard is loaded, you can select all the options you want to include within the cleanup, in my case, I only selected &#8220;Previous Windows Installation(s)&#8221; as shown in a print screen above. After a click on OK, the wizard writes this settings to the registry under &#8220;Computer\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches&#8221;, per each setting:<br \/>\n<a href=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old04.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old04.png?w=300\" alt=\"\" width=\"300\" height=\"257\" class=\"aligncenter size-medium wp-image-2661\" srcset=\"https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old04.png 1199w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old04-300x257.png 300w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old04-1024x878.png 1024w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old04-768x658.png 768w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nAs you can see on the previous picture, every setting from the wizard has a corresponding key within the registry. So if you have selected &#8220;Previous Windows Installation(s)&#8221;, you will find a new entry under &#8220;Previous Installations&#8221;, in my case named &#8220;StateFlags1703&#8221;, where the number from the parameter is represented:<br \/>\n<a href=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old06.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old06.png?w=300\" alt=\"\" width=\"300\" height=\"121\" class=\"aligncenter size-medium wp-image-2662\" srcset=\"https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old06.png 1038w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old06-300x121.png 300w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old06-1024x414.png 1024w, https:\/\/blog.hosebei.ch\/wp-content\/uploads\/2017\/11\/remove_windows-old06-768x311.png 768w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now you can export this, and import it within the Task Sequence, oder just write it through Powershell with the following command:<br \/>\n<code>New-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Previous Installations\\\" -Name \"StateFlags1703\" -Type DWORD -Value 2<\/code><\/p>\n<p>When this is done, you only need to call cleanmgr.exe with the &#8220;sagerun&#8221; parameter, and the not (?) documented silent parameter:<br \/>\n<code>cleanmgr.exe \/sagerun:1703 \/S<\/code><br \/>\nWithout the \/S parameter, the GUI will show up and requires you to press OK, what will not work within a TS.<\/p>\n<p>Hope this helps, and deleting the windows.old folder, I still recommend to do only if required, otherwise let the scheduled task do the magic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Long time no see, huh? Now I&#8217;m back with a new post about removing the Windows.old folder after a feature Upgrade. Recently I seen this on twitter, a commented it with: Why don&#8217;t you let the automation from Windows 10 let it do. But since then, I was in a project, where the removal of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,41,43],"tags":[],"class_list":["post-2653","post","type-post","status-publish","format-standard","hentry","category-operating-system-deployment","category-updates-management","category-windows-10"],"_links":{"self":[{"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=\/wp\/v2\/posts\/2653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2653"}],"version-history":[{"count":0,"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=\/wp\/v2\/posts\/2653\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hosebei.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}