Automate process of Disk Cleanup cleanmgr.exe without user intervention

后端 未结 6 2354
不知归路
不知归路 2020-12-29 06:54

I am developing a powershell script file which shall execute some disk cleanup without user intervention. The user shall not be able to configure anything.

When I ru

6条回答
  •  死守一世寂寞
    2020-12-29 07:54

    The only solution I found is to manually set the registry values like this:

    ...

    #Set StateFlags0012 setting for each item in Windows 8.1 disk cleanup utility
    if (-not (get-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders' -name StateFlags0012 -ErrorAction SilentlyContinue)) {
    set-itemproperty -path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders' -name StateFlags0012 -type DWORD -Value 2
    set-itemproperty -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\BranchCache' -name StateFlags0012 -type DWORD -Value 2
    set-itemproperty -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files' -name StateFlags0012 -type DWORD -Value 2
    

    ...

    see full example

提交回复
热议问题