Windows 10 1903 and Later 搜索中心居中脚本

网上冲浪时看到的一个有意思的 powershell 脚本。 在这里记录一下

首先更改策略允许执行powershell脚本

1
set-ExecutionPolicy RemoteSigned

然后执行如下脚本:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$BASE_PATH = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search'
$RADIUS_PATH = "$BASE_PATH\Flighting\Override"

function CustimizedNewItemProperty($Path, $Name, $Value) {
    $null = New-ItemProperty -Path $Path -Name $Name -PropertyType DWord -Value $Value
}

function ToCenter($Radius) {
    $null = ToDefault
    $null = New-Item -ItemType String -Path $RADIUS_PATH
    CustimizedNewItemProperty $BASE_PATH ImmersiveSearch 1
    CustimizedNewItemProperty $RADIUS_PATH ImmersiveSearchFull 1
    CustimizedNewItemProperty $RADIUS_PATH CenterScreenRoundedCornerRadius $Radius
    '设置成功'
}

function ToDefault {
    if (Test-Path -Path $RADIUS_PATH) {
        $null = Remove-Item -Path $RADIUS_PATH -Recurse -Force
    }
    if ($null -ne (Get-ItemProperty -Path $BASE_PATH | Select-String -Pattern "ImmersiveSearch")) {
        $null = Remove-ItemProperty -Path $BASE_PATH -Name ImmersiveSearch -Force
    }
    '恢复完成'
}

function Menu {
    Clear-Host
    @"
----------------------------
  Windows 10 1903 and Later
       Search 居中脚本
            V0.01 2019.10.02
                @AUTHOR LOGI
----------------------------
0. 退出
1. 居中
2. 恢复
----------------------------
"@
    switch (Read-Host '请选择') {
        0 { Exit 0 }
        1 { 
            try {
                ToCenter ([int](Read-Host '请输入圆角大小(0-10)'))
            }
            catch {
                ToCenter 0
            }
        }
        2 { ToDefault }
        Default { Menu }
    }
}

while ($true) {
    Menu
    '----------------------------'
    '请按任意键继续...'
    [void][System.Console]::ReadKey($true)
}

原文链接: https://logi.ml/script/center-win10-search-ui.html

Licensed under CC BY-NC-SA 4.0
FrostMiKu
Built with Hugo
主题 StackJimmy 设计