2024-06-04 20:27:27 -07:00
|
|
|
function Invoke-WinUtilSnapSuggestion {
|
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
|
|
|
|
Disables/Enables Snap Assist Suggestions on startup
|
|
|
|
|
.PARAMETER Enabled
|
|
|
|
|
Indicates whether to enable or disable Snap Assist Suggestions on startup
|
|
|
|
|
#>
|
|
|
|
|
Param($Enabled)
|
2024-08-06 23:35:17 +03:00
|
|
|
try {
|
|
|
|
|
if ($Enabled -eq $false) {
|
2024-06-04 20:27:27 -07:00
|
|
|
Write-Host "Enabling Snap Assist Suggestion On startup"
|
|
|
|
|
$value = 1
|
2024-08-06 23:35:17 +03:00
|
|
|
} else {
|
2024-06-04 20:27:27 -07:00
|
|
|
Write-Host "Disabling Snap Assist Suggestion On startup"
|
|
|
|
|
$value = 0
|
|
|
|
|
}
|
|
|
|
|
# taskkill.exe /F /IM "explorer.exe"
|
|
|
|
|
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
|
|
|
|
|
taskkill.exe /F /IM "explorer.exe"
|
|
|
|
|
Set-ItemProperty -Path $Path -Name SnapAssist -Value $value
|
|
|
|
|
Start-Process "explorer.exe"
|
2024-08-06 23:35:17 +03:00
|
|
|
} catch [System.Security.SecurityException] {
|
2024-06-04 20:27:27 -07:00
|
|
|
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
2024-08-06 23:35:17 +03:00
|
|
|
} catch [System.Management.Automation.ItemNotFoundException] {
|
2024-06-04 20:27:27 -07:00
|
|
|
Write-Warning $psitem.Exception.ErrorRecord
|
2024-08-06 23:35:17 +03:00
|
|
|
} catch {
|
2024-06-04 20:27:27 -07:00
|
|
|
Write-Warning "Unable to set $Name due to unhandled exception"
|
|
|
|
|
Write-Warning $psitem.Exception.StackTrace
|
|
|
|
|
}
|
2024-08-06 23:35:17 +03:00
|
|
|
}
|