清除 Windows Update 的更新补丁缓存

清除 Windows Update 的更新补丁缓存,您可以使用以下步骤:

  1. 打开 PowerShell(以管理员身份运行)。
  2. 运行以下命令来停止 Windows Update 服务:
    powershellCopy Code
    Stop-Service wuauserv
  3. 运行以下命令来删除软件分发文件夹中的更新缓存:
    powershellCopy Code
    Remove-Item -Path C:\Windows\SoftwareDistribution\Download\* -Force
    如果您的系统安装在非 C 驱动器上,请将路径相应地更改。
  4. 最后,运行以下命令来启动 Windows Update 服务:
    powershellCopy Code
    Start-Service wuauserv

通过执行以上步骤,您可以清除 Windows Update 的更新补丁缓存


 

命令列出计算机上当前存在的日志名称,以确认您要清除的日志是否存在:

powershellCopy Code
Get-EventLog -List

然后根据列出的日志名称列表,选择正确的日志名称来进行清除操作。


命令分别清除各个日志中的事件记录:

powershellCopy Code
Clear-EventLog -LogName Application
Clear-EventLog -LogName HardwareEvents
Clear-EventLog -LogName "Internet Explorer"
Clear-EventLog -LogName "Key Management Service"
Clear-EventLog -LogName OneApp_IGCC
Clear-EventLog -LogName Security
Clear-EventLog -LogName System
Clear-EventLog -LogName "Windows PowerShell"

请注意,上述命令会逐个清除指定日志中的所有事件记录。


  1. 清空回收站:
powershellCopy Code
Clear-RecycleBin -Force
  1. 清空旧的 Prefetch 文件:
powershellCopy Code
Get-ChildItem -Path "C:\Windows\Prefetch" | Remove-Item -Force

 

  1. 刷新 DNS 缓存:
powershellCopy Code
Clear-DnsClientCache

清空 Windows 桌面图标缓存,您可以按照以下步骤操作:

  1. 打开 PowerShell(以管理员身份运行)。
  2. 运行以下命令来停止 Windows Explorer 进程:
    powershellCopy Code
    Stop-Process -Name explorer -Force
  3. 运行以下命令来删除图标缓存文件:
    powershellCopy Code
    Remove-Item "$env:USERPROFILE\AppData\Local\IconCache.db" -Force
  4. 最后,运行以下命令来重新启动 Windows Explorer 进程:
    powershellCopy Code
    Start-Process explorer

通过执行以上步骤,您可以清空 Windows 的桌面图标缓存。重新启动 Windows Explorer 后,您应该能够看到新的图标缓存生效。


在 PowerShell 中,你可以使用 Set-ItemProperty 命令来修改文件的时间戳。具体来说,你可以修改文件的创建时间 (CreationTime)、最后访问时间 (LastAccessTime) 和最后修改时间 (LastWriteTime)。

下面是一个示例 PowerShell 脚本,演示如何修改文件的最后修改时间:

powershellCopy Code
# 设置文件路径和新的修改时间
$file = "C:\Path\To\Your\File.txt"
$newLastWriteTime = Get-Date "2022-01-01 12:00:00 PM"

# 获取文件对象
$targetFile = Get-Item $file

# 修改文件的最后修改时间
$targetFile.LastWriteTime = $newLastWriteTime

Write-Host "文件的最后修改时间已修改为: $newLastWriteTime"

请将脚本中的 $file 替换为你要修改时间戳的文件路径,将 $newLastWriteTime 替换为你希望设置的新的最后修改时间。

执行这个脚本时,请确保以管理员权限运行 PowerShell,因为有些文件可能需要管理员权限才能修改其属性。

 


 

posted @ 2024-02-29 07:09  suv789  阅读(149)  评论(0编辑  收藏  举报