禁用启动延时

Posted on 2019-03-29 17:54  努力成长静待花开  阅读(149)  评论(0编辑  收藏  举报

使用说明:

Open-StartDelay -off   #禁用启动延时

Open-StartDelay    #恢复默认

实现代码:

    function Open-StartDelay([Switch]$off)
    {
        $regkey='HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Serialize'
        $falg=Test-Path $regkey
        if((-not $falg)-and !$off.IsPresent){ 
           New-Item -ItemType Directory -Path $regkey|Out-Null
           $null=New-ItemProperty -Path $regkey -Name StartupDelayInMSec -Value 0 -Type DWORD
        }elseif($falg -and $off.IsPresent){
            Remove-Item -Path $regkey -Force
        }
    }