好的,我需要一个批处理命令(FOR
也许是一个循环?)来检查多个注册表项是否存在StateFlags0001
密钥。
如果密钥不存在,则创建它并将其设置value
为0x2
. 如果确实存在,请确保将其值设置为0x2
。
我知道我可以用一些聪明的命令来做这个“很长的路” IF
,但我想知道它是否可以以某种方式大大简化。
最终,我希望cleanmgr /sagerun:1
命令通过批处理自动化,这样我就可以取消cleanmgr /sageset:1
命令,因为这个批处理将被发送给一些对在计算机上执行基本任务一无所知的朋友和家人。让他们运行批处理文件会容易得多,然后我可以引导他们完成cleanmgr sageset:1
命令之后/期间的步骤......
在有人问“为什么不简单地将VolumeCaches
文件夹中的所有内容设置为您需要的内容?”之前,我已经省略了几个键,因为我不希望它们包含在清理过程中,所以这不是一个选项。
当然,如果更容易执行我的请求并忽略它们并在剩余的内容上运行循环(即下面的键),那么无论如何,让我们这样做......
这是有问题的键:
REG QUERY "HKLM\\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Downloaded Program Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Internet Cache Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Memory Dump Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Old ChkDsk Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Recycle Bin" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Setup Log Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error minidump files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Upgrade Discarded Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Archive Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting Queue Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Archive Files" /v "StateFlags0001" | Find "0x2"
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Windows Error Reporting System Queue Files" /v "StateFlags0001" | Find "0x2"
所以,简而言之;
检查上面的键StateFlags0001
。如果存在,请确保值为0x2
. 如果不存在,则创建它并将值设置为0x2
。运行cleanmgr /sagerun:1
。出口。
一如既往,感谢您的启发!!!;)