AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1423464
Accepted
acgbox
acgbox
Asked: 2019-04-10 11:56:12 +0800 CST2019-04-10 11:56:12 +0800 CST 2019-04-10 11:56:12 +0800 CST

使用注册表键/命令行在 Windows 10/8/7 中打开或关闭磁盘写入缓存

  • 772

根据 Microsoft 的说法,在 Windows 10/8/7 中,打开或关闭磁盘写入缓存:

  1. 用鼠标右键单击我的电脑,然后单击属性。
  2. 单击硬件选项卡,然后单击设备管理器。
  3. 展开磁盘驱动器。
  4. 右键单击要打开或关闭磁盘写入缓存的驱动器,然后单击“属性”。
  5. 单击策略选项卡。
  6. 单击以根据需要选中或清除在磁盘上启用写入缓存复选框。
  7. 单击确定。

在此处输入图像描述

如何使用注册表项 (regedit) / 命令行打开或关闭磁盘写入缓存?(在多台 PC 上自动执行该过程)

PD: C/C++ 中有一个选项,但它已过时或不适用。这同样适用于dskcache 使用的方法。

window regedit
  • 2 2 个回答
  • 6532 Views

2 个回答

  • Voted
  1. Best Answer
    ynaka
    2019-05-11T05:46:42+08:002019-05-11T05:46:42+08:00

    好像是微软发的一个旧的diskcache.exe丢了。试试我很久以前制作的兼容工具。

    https://www.vector.co.jp/soft/winnt/hardware/se487753.html

    要在磁盘 0 上启用写缓存,

    .\diskcach 0 -w 1
    

    禁用

    .\diskcach 0 -w 0
    

    它可能需要 MSVC++ 2008 SP1 可再发行组件包。

    • 2
  2. farag
    2021-03-03T02:45:01+08:002021-03-03T02:45:01+08:00

    我创建了一个函数来启用/禁用仅为系统驱动器的写入磁盘缓存。需要重新启动。

    永久链接:https ://github.com/farag2/Utilities/blob/master/Enable_disk_write_caching.ps1

    <#
        .SYNOPSIS
        Configure the disk write caching
    
        .PARAMETER Disable
        Disable the disk write caching
    
        .PARAMETER Enable
        Enable the disk write caching
    
        .EXAMPLE
        DiskWriteCaching -Disable
    
        .EXAMPLE
        DiskWriteCaching -Enable
    
        .NOTES
        Current user
    #>
    function DiskWriteCaching
    {
        param
        (
            [Parameter(
                Mandatory = $true,
                ParameterSetName = "Disable"
            )]
            [switch]
            $Disable,
    
            [Parameter(
                Mandatory = $true,
                ParameterSetName = "Enable"
            )]
            [switch]
            $Enable
        )
    
        # Get system drive ID regardless of the port number
        $Index = (Get-Partition | Where-Object -FilterScript {$_.DriveLetter -eq $env:SystemDrive[0]}).DiskNumber
        $SystemDriveID = (Get-CimInstance -ClassName CIM_DiskDrive | Where-Object -FilterScript {$_.Index -eq $Index}).PNPDeviceID
        # Get system drive instance
        $PSPath = (Get-ChildItem -Path HKLM:\SYSTEM\CurrentControlSet\Enum\SCSI | Where-Object -FilterScript {$SystemDriveID -match $_.PSChildName}).PSPath
        # We need to go deeper... LeonardoDiCaprio.jpg
        $PSPath = (Get-ChildItem -Path $PSPath | Where-Object -FilterScript {$SystemDriveID -match $_.PSChildName}).PSPath
    
        # Check whether disk write caching is enabled
        $IsDeviceCacheEnabled = (Get-StorageAdvancedProperty -PhysicalDisk (Get-PhysicalDisk | Where-Object -FilterScript {$_.DeviceID -eq $Index})).IsDeviceCacheEnabled
    
        switch ($PSCmdlet.ParameterSetName)
        {
            "Disable"
            {
                if ($IsDeviceCacheEnabled)
                {
                    if (-not (Test-Path -Path "$PSPath\Device Parameters\Disk"))
                    {
                        # Create "Disk" folder
                        New-Item -Path "$PSPath\Device Parameters\Disk" -Force
                    }
    
                    # Disable disk write caching
                    New-ItemProperty -Path "$PSPath\Device Parameters\Disk" -Name UserWriteCacheSetting -PropertyType DWord -Value 0 -Force
                    New-ItemProperty -Path "$PSPath\Device Parameters\Disk" -Name CacheIsPowerProtected -PropertyType DWord -Value 0 -Force
                }
            }
            "Enable"
            {
                if (-not $IsDeviceCacheEnabled)
                {
                    if (-not (Test-Path -Path "$PSPath\Device Parameters\Disk"))
                    {
                        # Create "Disk" folder
                        New-Item -Path "$PSPath\Device Parameters\Disk" -Force
                    }
    
                    # Enable disk write caching
                    New-ItemProperty -Path "$PSPath\Device Parameters\Disk" -Name UserWriteCacheSetting -PropertyType DWord -Value 1 -Force
                    New-ItemProperty -Path "$PSPath\Device Parameters\Disk" -Name CacheIsPowerProtected -PropertyType DWord -Value 0 -Force
                }
            }
        }
    
        Write-Warning "Make sure to restart your PC!"
    }
    
    # DiskWriteCaching -Disable
    # DiskWriteCaching -Enable
    
    • 1

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve